List of usage examples for android.app FragmentTransaction replace
public abstract FragmentTransaction replace(@IdRes int containerViewId, Fragment fragment);
From source file:jsettlers.main.android.JsettlersActivity.java
public void showFragment(JsettlersFragment fragment) { FragmentManager manager = getFragmentManager(); if (!fragment.shouldAddToBackStack()) { manager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); }// w w w . jav a 2s. co m FragmentTransaction transaction = manager.beginTransaction(); if (fragment.shouldAddToBackStack()) { transaction.addToBackStack(fragment.getName()); } transaction.replace(R.id.base_menu, fragment); transaction.commit(); }
From source file:robert843.o2.pl.player.ui.PlaceholderActivity.java
private void navigateToBrowser(String mediaId) { LogHelper.d(TAG, "navigateToBrowser, mediaId=" + mediaId); MediaBrowserFragment fragment = getBrowseFragment(); if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) { fragment = new MediaBrowserFragment(); fragment.setMediaId(mediaId);//from www .j av a2s. com FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.animator.slide_in_from_right, R.animator.slide_out_to_left, R.animator.slide_in_from_left, R.animator.slide_out_to_right); transaction.replace(R.id.container, fragment); // If this is not the top level media (root), we add it to the fragment back stack, // so that actionbar toggle and Back will work appropriately: if (mediaId != null) { transaction.addToBackStack(null); } transaction.commit(); } }
From source file:com.example.koppa.driverlicensev2.MainActivity.java
public void addStatisticFragment() { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); StatisticFragment statisticFragment = new StatisticFragment(); statisticFragment.setUserModel(userModel); fragmentTransaction.replace(R.id.fragment_container, statisticFragment); fragmentTransaction.commit();/*from w ww. ja v a 2s .com*/ }
From source file:com.twp.music.MainActivity.java
private void changePage(PageType type) { Fragment fg = null;//from w w w. j a v a2 s .c o m switch (type) { case FINDMUSIC: fg = new FindMusicFragment(); break; case MYMUSIC: fg = new MyMusicFragment(); break; default: break; } FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.content, fg); ft.commit(); }
From source file:com.andreykaraman.multinote.ui.list.AltNoteActivity.java
public void onArticleSelected(int position, long id) { // The user selected the headline of an article from the // HeadlinesFragment // Capture the article fragment from the activity layout AltEditNoteFragment articleFrag = (AltEditNoteFragment) getFragmentManager() .findFragmentById(R.id.fragment_new_note); if (articleFrag != null) { // If article frag is available, we're in two-pane layout... // Call a method in the ArticleFragment to update its content articleFrag.updateArticleView(position); } else {/*from ww w . ja v a 2 s. c om*/ // If the frag is not available, we're in the one-pane layout and // must swap frags... // Create fragment and give it an argument for the selected article AltEditNoteFragment newFragment = new AltEditNoteFragment(); Bundle args = new Bundle(); args.putLong(AltEditNoteFragment.ARG_ID, id); newFragment.setArguments(args); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this // fragment, // and add the transaction to the back stack so the user can // navigate back transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); } }
From source file:org.fundsofhope.androidapp.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_sliding); RecyclerView recList = (RecyclerView) findViewById(R.id.cardList); recList.setHasFixedSize(true);/*from w w w . j a va 2s . c om*/ Button add; add = (Button) findViewById(R.id.fab_button); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Log.i(TAG, "loged in as" + String.valueOf(pref.getInt("user", -1))); add.setClickable(true); //Bitmap bi; add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent inte = new Intent(MainActivity.this, GoogleLoginActivity.class); startActivity(inte); finish(); } }); // Pushbots.sharedInstance().init(this); temp = 2; final SharedPreferences ppref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); token = ppref.getString("token", ""); new LoginTask().execute(""); if (savedInstanceState == null) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); SlidingTabsBasicFragment fragment = new SlidingTabsBasicFragment(); transaction.replace(R.id.sample_content_fragment, fragment); transaction.commit(); } configureToolbar(); configureDrawer(); }
From source file:de.j4velin.pedometer.ui.Activity_Main.java
@Override protected void onCreate(final Bundle b) { super.onCreate(b); startService(new Intent(this, SensorListener.class)); if (b == null) { // Create new fragment and transaction Fragment newFragment = new Fragment_Overview(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this // fragment, // and add the transaction to the back stack transaction.replace(android.R.id.content, newFragment); // Commit the transaction transaction.commit();//from ww w .jav a2 s .c o m } GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this, this, this); builder.addApi(Games.API, Games.GamesOptions.builder().build()); builder.addScope(Games.SCOPE_GAMES); builder.addApi(Fitness.HISTORY_API); builder.addApi(Fitness.RECORDING_API); builder.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE)); mGoogleApiClient = builder.build(); }
From source file:com.android.calendar.SearchActivity.java
private void initFragments(long timeMillis, String query) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); AgendaFragment searchResultsFragment = new AgendaFragment(timeMillis, true); ft.replace(R.id.search_results, searchResultsFragment); mController.registerEventHandler(R.id.search_results, searchResultsFragment); ft.commit();/*from w w w . j a v a 2s . c o m*/ Time t = new Time(); t.set(timeMillis); search(query, t); }
From source file:de.azapps.mirakel.settings.model_settings.generic_list.GenericModelListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (MirakelCommonPreferences.isDark()) { setTheme(R.style.AppBaseThemeDARK); }//from w ww. j a v a 2 s . c om super.onCreate(savedInstanceState); setContentView(R.layout.activity_generic_model_twopane); // Show the Up button in the action bar. getActionBar().setDisplayHomeAsUpEnabled(true); mDetailContainer = (FrameLayout) findViewById(R.id.generic_model_detail_container); mTwoPane = MirakelCommonPreferences.isTablet(); mDetailContainer.setVisibility(mTwoPane ? View.VISIBLE : View.GONE); final FragmentTransaction transaction = getFragmentManager().beginTransaction() .replace(R.id.generic_model_list_container, new GenericModelListFragment<T>()); if (mTwoPane) { if (!isSupport()) { transaction.replace(R.id.generic_model_detail_container, instanceDetail(getDefaultItem())); } else { getSupportFragmentManager().beginTransaction() .replace(R.id.generic_model_detail_container, instanceSupportDetail(getDefaultItem())) .commit(); } } transaction.commit(); }
From source file:de.sourcestream.movieDB.controller.GenresList.java
/** * Callback method to be invoked when an item in this AdapterView has been clicked. * * @param parent The AdapterView where the click happened. * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) * @param position The position of the view in the adapter. * @param id The row id of the item that was clicked. *//*from w ww. j ava2 s .c o m*/ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (movieList.getCurrentList().equals("genre/" + genresList.get(position).getId() + "/movies")) movieList.setBackState(1); else { movieList.setCurrentList("genre/" + genresList.get(position).getId() + "/movies"); movieList.setBackState(0); } movieList.setTitle(genresList.get(position).getName()); FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle args = new Bundle(); args.putString("currentList", "genresList"); movieList.setArguments(args); transaction.replace(R.id.frame_container, movieList); // add the current transaction to the back stack: transaction.addToBackStack("genresList"); transaction.commit(); backState = 1; }