List of usage examples for android.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:io.demiseq.jetreader.activities.MainActivity.java
private void GetHotMangas() { MainFragment fragment = new MainFragment(); Bundle args = new Bundle(); args.putInt("manga_type", 1); fragment.setArguments(args);/*from w w w . j a v a 2 s . c o m*/ FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "HOT"); fragmentTransaction.commit(); removeSpinner(); setTitle(app_name); }
From source file:io.demiseq.jetreader.activities.MainActivity.java
private void GetFavoriteMangas() { MainFragment fragment = new MainFragment(); Bundle args = new Bundle(); args.putInt("manga_type", 2); fragment.setArguments(args);/* w w w . ja va 2 s . c om*/ FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "FAVOURITE"); fragmentTransaction.commit(); removeSpinner(); setTitle(favorite); }
From source file:com.esri.android.mapsapp.MapsAppActivity.java
/** * Opens the map represented by the specified portal item or if null, opens * a default map./*www .jav a 2s.com*/ */ public void showMap(String portalItemId, String basemapPortalItemId) { // remove existing MapFragment explicitly, simply replacing it can cause // the app to freeze when switching basemaps FragmentTransaction transaction; FragmentManager fragmentManager = getFragmentManager(); Fragment currentMapFragment = fragmentManager.findFragmentByTag(MapFragment.TAG); if (currentMapFragment != null) { transaction = fragmentManager.beginTransaction(); transaction.remove(currentMapFragment); transaction.commit(); } MapFragment mapFragment = MapFragment.newInstance(portalItemId, basemapPortalItemId); transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.maps_app_activity_content_frame, mapFragment, MapFragment.TAG); transaction.addToBackStack(null); transaction.commit(); invalidateOptionsMenu(); // reload the options menu }
From source file:io.demiseq.jetreader.activities.MainActivity.java
private void GetCategories(Category c) { if (spinnerContainer == null) setUpSpinner();//from www .java2s . co m CategoryFragment fragment = new CategoryFragment(); Bundle bundle = new Bundle(); bundle.putString("url", c.getUrl()); bundle.putInt("max_page", c.getPage()); bundle.putInt("position", categories.indexOf(c)); fragment.setArguments(bundle); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment, "CATEGORY"); fragmentTransaction.commit(); }
From source file:com.coderdojo.libretalk.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new BackgroundFragment(); Bundle args = new Bundle(); args.putInt(BackgroundFragment.ARG_BACKGROUND, position); fragment.setArguments(args);// ww w. ja v a 2 s.c om 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); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.ternup.caddisfly.fragment.ResultFragment.java
private void goBack() { FragmentManager fm = getFragmentManager(); try {//from w w w . ja va 2 s . c o m if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); fm.executePendingTransactions(); } else { Fragment fragment = new HomeFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.executePendingTransactions(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.replace(R.id.container, fragment, "0"); ft.addToBackStack(null); ft.commit(); fm.executePendingTransactions(); ListView drawerList = (ListView) getActivity().findViewById(R.id.navigation_drawer); drawerList.setItemChecked(0, true); drawerList.setSelection(0); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.vaporwarecorp.mirror.feature.main.MirrorActivity.java
private void hideFragment(final Fragment fragment, final boolean removeParentView, final boolean addedToBackStack, final String tag) { final FragmentManager manager = getFragmentManager(); if (manager.findFragmentByTag(tag) != null) { final FragmentTransaction transaction = manager.beginTransaction(); transaction.remove(fragment);/*ww w .j a v a 2 s.c o m*/ transaction.commit(); if (addedToBackStack) { manager.popBackStack(); } final int viewId = getParentId(fragment); if (removeParentView && viewId != 0) { mContentContainer.removeBorderView(viewId); } } }
From source file:com.example.android.shuttershock.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new filterFragment(); Bundle args = new Bundle(); args.putInt(filterFragment.ARG_filter_NUMBER, position); fragment.setArguments(args);/*from ww w . j a 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(mfilterTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); /* if (position == 0) { readDates(); dataList.setAdapter(adapter); } */ }
From source file:com.coderdojo.libretalk.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from w w w .j a v a 2 s . com*/ // Handle action buttons switch (item.getItemId()) { case R.id.action_addfriend: Fragment fragment = new AddFriendFragment(); Bundle args = new Bundle(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); return true; case R.id.action_websearch: // create intent to perform web search for this planet Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, getActionBar().getTitle()); // catch event that there's no activity to handle intent if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.vaporwarecorp.mirror.feature.main.MirrorActivity.java
private void showDialogFragment(final FragmentManager fragmentManager, final DialogFragment dialogFragment, final boolean addToBackStack, final String tag) { final FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(dialogFragment, tag); if (addToBackStack) { transaction.addToBackStack(tag); }/*from w w w.j a v a2s. co m*/ transaction.commitAllowingStateLoss(); }