FragmentActivity getSupportFragmentManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for FragmentActivity getSupportFragmentManager method.

This code example shows how to use the following methods:getSupportFragmentManager, onCreate
import com.jakewharton.android.mapsforge_fragment.MapViewMode; 
 
public class SampleActivity extends FragmentActivity { 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getSupportFragmentManager().beginTransaction().add(android.R.id.content, new SampleMapFragment()).commit();
	} 
 
	private static class SampleMapFragment extends MapFragment {
		public SampleMapFragment() { 
			super(MapViewMode.OSMARENDER_TILE_DOWNLOAD); 
		} 
 
		@Override 
		public MapView onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
			MapView view = super.onCreateView(inflater, container, savedInstanceState);
 
			view.setClickable(true);
			view.setBuiltInZoomControls(true);
6
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, onKeyDown
		case KeyEvent.KEYCODE_BACK:
			if(handleBackKeyEvent()) { 
				return true; 
			} 
		} 
		return super.onKeyDown(keyCode, event);
	} 
	 
	/* 
	 * METHODS 
	 */ 
	 
	public boolean handleBackKeyEvent() { 
		//check if there are no remaining FragmentTransactions in the backstack 
		if(getSupportFragmentManager().getBackStackEntryCount() > 0) { 
			if(DEBUG) Log.d(TAG, "...some remaining backstack entries...");
			getSupportFragmentManager().popBackStack(); 
			return true; 
		} else { 
			if(DEBUG) Log.d(TAG, "...no remaining backstack entries...");

6
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, getLayoutFragmentContainerId
		} 
	} 
 
	public boolean onKeyDown(int keyCode, KeyEvent event) {
	    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
	    	FragmentManager fragManager = getSupportFragmentManager();
	    	FragmentTransaction backTransaction = fragManager.beginTransaction();
	    	Fragment frag = fragManager.findFragmentById(getLayoutFragmentContainerId());
	    	if(frag != null) {
	    		backTransaction.detach(frag);
	    		backTransaction.commit();
	    	} 
	    } 
	    return super.onKeyDown(keyCode, event);
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, onCreate
	 
	private MainFragment mainFragment; 
	 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
         
        if (savedInstanceState == null) { 
        	// Add the fragment on initial activity setup 
        	mainFragment = new MainFragment(); 
            getSupportFragmentManager() 
            .beginTransaction() 
            .add(android.R.id.content, mainFragment) 
            .commit(); 
        } else { 
        	// Or set the fragment from restored state info 
        	mainFragment = (MainFragment) getSupportFragmentManager() 
        	.findFragmentById(android.R.id.content); 
        } 
    } 

5
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, getApplicationContext, onCreate
 
public class AboutActivity extends FragmentActivity { 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        ((AppHelper) getApplicationContext()).updateUiLanguage(); 
 
        FragmentManager fm = getSupportFragmentManager();
 
        if (fm.findFragmentById(android.R.id.content) == null) {
            AboutFragment about = new AboutFragment();
            fm.beginTransaction().add(android.R.id.content, about).commit();
        } 
 
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            getActionBar().setHomeButtonEnabled(true); 
        } 
    } 
5
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, onCreate
 
    private static final String TAG = GenreListFragmentActivity.class.getSimpleName();
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        FragmentManager fm = getSupportFragmentManager();
 
        // Create the list fragment and add it as our sole content. 
        if (fm.findFragmentById(android.R.id.content) == null) {
            GenreListFragment list = new GenreListFragment();
            fm.beginTransaction().add(android.R.id.content, list).commit();
        } 
    } 
 
    // Utility class to store the View ID's retrieved from the layout only once for efficiency 
    static class GenreViewHolder { 
 
        TextView genre;
5
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, onCreate
public class ImageGridActivity extends FragmentActivity { 
    private static final String TAG = "ImageGridFragment";
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
  //      setContentView(R.layout.main); 
 
        if (getSupportFragmentManager().findFragmentByTag(TAG) == null) {
            final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
/*            ft.add(R.id.container1, new ImageGridFragment(), TAG); 
            ft.add(R.id.container1, new ImageGridFragment(), TAG); 
//            ft.add(R.id.container2, new ImageGridFragment(), TAG); 
*/             
            ft.add(android.R.id.content, new ImageGridFragment(), TAG);
            ft.add(android.R.id.content, new ImageGridFragment(), TAG);
//            ft.add(android.R.id.content, new ImageGridFragment(), TAG); 
            ft.commit();
        } 
    } 
5
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, onCreate
import android.widget.ListView; 
 
public class MyFragClass extends FragmentActivity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
 
	FragmentManager fm = getSupportFragmentManager();
 
	// Create the list fragment and add it as our sole content. 
	if (fm.findFragmentById(android.R.id.content) == null) {
	    AppListFragment list = new AppListFragment();
	    fm.beginTransaction().add(android.R.id.content, list).commit();
	} 
    } 
 
    public static class AppListFragment extends ListFragment implements
	    LoaderManager.LoaderCallbacks<List<String>> {
 
	// This is the Adapter being used to display the list's data. 
5
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, onSaveInstanceState
    } 
 
	@Override 
	public void onSaveInstanceState(Bundle outState)
	{ 
	    super.onSaveInstanceState(outState);
        getSupportFragmentManager().putFragment(outState,"showEntryFragment",
        		                                showEntryFragment);   
	}   
	 
 
 
    public void addEntryLayout_AddCallback(View view) 
    {      
    	String validationErrorString = showEntryFragment.validate();
    	if(validationErrorString == null)
    	{ 
    		RowItem rowItem = showEntryFragment.getEntry();
    		rowItem.setChecked(false);
            databaseInterface.insertRow(rowItem);
4
CodeRank
This code example shows how to use the following methods:getSupportFragmentManager, findViewById
  
    /** 
     * Step 2: Setup TabHost 
     */ 
    private void initialiseTabHost(Bundle args) {
        mTabHost = (TabHost)findViewById(android.R.id.tabhost);
        mTabHost.setup();
        TabInfo tabInfo = null;
        TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator("Overview"), ( tabInfo = new TabInfo("Tab1", TabFragment1.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("Feeds"), ( tabInfo = new TabInfo("Tab2", TabFragment2.class, args)));
        this.mapTabInfo.put(tabInfo.tag, tabInfo);
        // Default to first tab 
        this.onTabChanged("Tab1");
        // 
        mTabHost.setOnTabChangedListener(this);
    } 
  
    /** 
     * @param activity 

4
CodeRank
getSupportFragmentManager Method Overview
Return the FragmentManager for interacting with fragments associated with this activity.
See Code Examples for other Android FragmentActivity Methods: