Back to project page Action-Bar-Fragment-Example.
The source code is released under:
Copyright (c) 2012, Feig Dev, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project Action-Bar-Fragment-Example listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.feigdev.fragmentex; //from w w w . jav a2 s . co m import android.graphics.Point; import android.os.Bundle; import android.support.v4.app.ActionBar; import android.support.v4.app.FragmentActivity; import android.widget.ArrayAdapter; public class FragmentExampleActivity extends FragmentActivity implements ActionBar.OnNavigationListener{ Point imgSize; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(this, R.array.locations, R.layout.abs__simple_spinner_item); list.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); getSupportActionBar().setListNavigationCallbacks(list, this); } @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { switch ((int)itemId){ case 0: getSupportFragmentManager() .beginTransaction() .replace(android.R.id.content, GridFragment.newInstance(itemPosition)) .commit(); break; case 1: getSupportFragmentManager() .beginTransaction() .replace(android.R.id.content, WebFragment.newInstance(itemPosition)) .commit(); break; } return true; } }