List of usage examples for android.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:rshankar.hindismsinhindi.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new MessageFragment(); Bundle args = new Bundle(); args.putInt(MessageFragment.ARG_PLANET_NUMBER, position); args.putString("title", mCategories.get(position).getCategoryName()); args.putInt("catId", mCategories.get(position).getCategoryId()); fragment.setArguments(args);/* w w w.ja v a 2 s . c o m*/ FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:org.qtproject.android.gallery.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new ControlFragment(); Bundle args = new Bundle(); args.putInt(ControlFragment.ARG_PAGE_NUMBER, position); fragment.setArguments(args);/*from w w w . ja v a 2 s . co m*/ FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPageTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.rastating.droidbeard.fragments.ShowsFragment.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { view.setSelected(true);//from ww w . j av a 2s .c o m TVShowSummary show = mAdapter.getItem(position); if (show != null) { FragmentManager manager = this.getFragmentManager(); ShowFragment fragment = new ShowFragment(); fragment.setTvShowSummary(show); manager.beginTransaction().replace(R.id.container, fragment).commit(); } if (floatingActionsMenu != null) { floatingActionsMenu.setVisibility(View.INVISIBLE); } }
From source file:com.example.tobias.androidtestapp.navigationdrawer.NavigationDrawerMain.java
private void selectItem(int position) { // update the main content by replacing fragments (PlanetFragment = innere Klasse) Fragment fragment = new PlanetFragment(); Bundle args = new Bundle(); args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(args);/*from w ww .jav a 2 s.c o m*/ FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.app.opencity.activities.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = null;/* w ww . j av a2 s . c om*/ switch (position) { case 0: fragment = DashBoardFragment.newInstance(position + 1); break; case 1: fragment = MapsFragment.newInstance(position + 1); break; case 2: { if (!mIsProfile) fragment = LoginFragment.newInstance(position + 1); else fragment = ProfileFragment.newInstance(position + 1); } break; default: break; } FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:de.fhb.mi.paperfly.user.FriendListFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { Log.d(TAG, "onItemClick"); Fragment fragment = new UserProfileFragment(); Bundle args = new Bundle(); args.putString(UserProfileFragment.ARGS_USER, listAdapter.getItem(position).getUsername()); args.putBoolean(UserProfileFragment.ARGS_USER_IS_FRIEND, true); fragment.setArguments(args);//from ww w.ja v a 2 s. c om // Insert the fragment by replacing any existing fragment FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); }
From source file:com.bewareofraj.mytvtracker.MainActivity.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override/*from w w w. j a va 2s.com*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTitle = mDrawerTitle = getTitle(); mMenuItems = getResources().getStringArray(R.array.main_menu_items); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer // opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mMenuItems)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setHomeButtonEnabled(true); } // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } // Load Watch List by default WatchListFragment fragment = new WatchListFragment(); FragmentManager fm = getFragmentManager(); fm.beginTransaction().replace(R.id.content_frame, fragment).commit(); }
From source file:com.example.android.reward.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new EndTripFragment(); Bundle args = new Bundle(); args.putInt(EndTripFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(args);// w w w. j a v a 2 s. c o m FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); //ft.replace(R.id.content_frame, fragment); ft.add(R.id.content_frame, fragment); ft.addToBackStack("null"); ft.commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:org.dolphinemu.dolphinemu.GameListActivity.java
private void recreateFragment() { mCurFragment = new GameListFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); }
From source file:com.pickr.activities.FlickrActivity.java
/** * Show a fragment in the main view/* w ww . ja v a 2s.c o m*/ * * @param item The fragment to display */ private void showFragment(Item<FlickrFragment> item) { FlickrFragment fragment = item.getValue(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.flickrFragmentsLayout, fragment, fragment.getClass().getSimpleName()); transaction.commit(); getActionBar().setTitle(fragment.getTitle()); mCurrentFragment = fragment; for (Item<FlickrFragment> item2 : mDrawerListItems) { item2.setSelected(false); } item.setSelected(true); mDrawerListAdapter.notifyDataSetChanged(); }