Search in sources :

Example 26 with FragmentManager

use of android.support.v4.app.FragmentManager in project facebook-android-sdk by facebook.

the class MainActivity method showFragment.

void showFragment(int fragmentIndex, boolean addToBackStack) {
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction transaction = fm.beginTransaction();
    if (addToBackStack) {
        transaction.addToBackStack(null);
    } else {
        int backStackSize = fm.getBackStackEntryCount();
        for (int i = 0; i < backStackSize; i++) {
            fm.popBackStack();
        }
    }
    for (int i = 0; i < fragments.length; i++) {
        if (i == fragmentIndex) {
            transaction.show(fragments[i]);
        } else {
            transaction.hide(fragments[i]);
        }
    }
    transaction.commit();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 27 with FragmentManager

use of android.support.v4.app.FragmentManager in project facebook-android-sdk by facebook.

the class MainActivity method onSaveInstanceState.

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean(SHOWING_SETTINGS_KEY, isShowingSettings());
    FragmentManager manager = getSupportFragmentManager();
    manager.putFragment(outState, SettingsFragment.TAG, settingsFragment);
    manager.putFragment(outState, ProfileFragment.TAG, profileFragment);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager)

Example 28 with FragmentManager

use of android.support.v4.app.FragmentManager in project PocketHub by pockethub.

the class MainActivity method switchFragment.

@VisibleForTesting
void switchFragment(Fragment fragment, User organization) {
    if (organization != null) {
        Bundle args = new Bundle();
        args.putParcelable("org", organization);
        fragment.setArguments(args);
    }
    FragmentManager manager = getSupportFragmentManager();
    manager.beginTransaction().replace(R.id.container, fragment).commit();
    drawerLayout.closeDrawer(GravityCompat.START);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Bundle(android.os.Bundle) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 29 with FragmentManager

use of android.support.v4.app.FragmentManager in project carat by amplab.

the class MainActivity method replaceFragment.

/*
	 * shows the fragment using a fragment transaction (replaces the FrameLayout
	 * (a placeholder in the main activity's layout file) with the passed-in fragment)
	 * 
	 * @param fragment the fragment that should be shown
	 * @param tag a name for the fragment to be shown in the
	 * fragment (task) stack
	 */
public void replaceFragment(Fragment fragment, String tag, boolean showDrawerIndicator) {
    // use a fragment tag, so that later on we can find the currently displayed fragment
    final String FRAGMENT_TAG = tag;
    // replace the fragment, using a fragment transaction
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.content_frame, fragment, FRAGMENT_TAG).addToBackStack(FRAGMENT_TAG).commit();
    mDrawerToggle.setDrawerIndicatorEnabled(showDrawerIndicator);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 30 with FragmentManager

use of android.support.v4.app.FragmentManager in project robolectric by robolectric.

the class ShadowDialogFragmentTest method removeUsingTransaction_shouldDismissTheDialog.

@Test
public void removeUsingTransaction_shouldDismissTheDialog() throws Exception {
    dialogFragment.show(fragmentManager, null);
    FragmentTransaction t = fragmentManager.beginTransaction();
    t.remove(dialogFragment);
    t.commit();
    Dialog dialog = ShadowDialog.getLatestDialog();
    assertFalse(dialog.isShowing());
    assertTrue(shadowOf(dialog).hasBeenDismissed());
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Dialog(android.app.Dialog) ShadowDialog(org.robolectric.shadows.ShadowDialog) Test(org.junit.Test)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)293 FragmentTransaction (android.support.v4.app.FragmentTransaction)106 Fragment (android.support.v4.app.Fragment)99 View (android.view.View)53 TextView (android.widget.TextView)35 Bundle (android.os.Bundle)31 OnClickListener (android.view.View.OnClickListener)24 DialogFragment (android.support.v4.app.DialogFragment)23 Intent (android.content.Intent)20 ImageView (android.widget.ImageView)16 ScrollView (android.widget.ScrollView)14 ListFragment (android.support.v4.app.ListFragment)12 Button (android.widget.Button)11 ArrayList (java.util.ArrayList)9 FrontPageFragment (ingage.ingage20.fragments.FrontPageFragment)8 SearchResultFragment (ingage.ingage20.fragments.SearchResultFragment)8 ViewPager (android.support.v4.view.ViewPager)7 ActionBar (android.support.v7.app.ActionBar)7 RecyclerView (android.support.v7.widget.RecyclerView)7 CategoriesPageFragment (ingage.ingage20.fragments.CategoriesPageFragment)7