FragmentManager findFragmentById - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:beginTransaction, findFragmentById
        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) {
            CursorLoaderListFragment list = new CursorLoaderListFragment();
            fm.beginTransaction().add(android.R.id.content, list).commit();
        } 
    } 
 
 
    public static class CursorLoaderListFragment extends ListFragment
            implements LoaderManager.LoaderCallbacks<Cursor> {
 
        // This is the Adapter being used to display the list's data. 
        SimpleCursorAdapter mAdapter;
 
        // If non-null, this is the current filter the user has provided. 
        String mCurFilter;
7
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentById
		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)
		{ 
			ReceiversListFragment list = new ReceiversListFragment();
			fm.beginTransaction().add(android.R.id.content, list).commit();
		} 
	} 
 
	public static class ReceiversListFragment extends SherlockListFragment 
	{ 
 
		/** 
		 * The logging TAG 
		 */ 
		private static final String TAG = "ReceiversListFragment";
 
6
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentById
        UIHelp.setupActionBar(this);
 
        FragmentManager fm = getSupportFragmentManager();
 
        // Create the list fragment and add it as our sole content. 
        if (fm.findFragmentById(android.R.id.content) == null) {
            AgenciesFragment list = new AgenciesFragment();
            fm.beginTransaction().add(android.R.id.content, list).commit();
        } 
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            NavHelp.goHome(this);
            return true; 
        } 
        return false; 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentById
	} 
 
	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:beginTransaction, findFragmentById
  @Override 
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
 
    FragmentManager fm = getSupportFragmentManager();
    if(fm.findFragmentById(android.R.id.content) == null){
      searchFrag = new RandomSearchFragment();
      fm.beginTransaction().add(android.R.id.content, searchFrag).commit();
    } 
  } 
} 
6
CodeRank
This code example shows how to use the following methods:findFragmentById
        return false; 
    } 
 
    public ArrivalsListFragment getArrivalsListFragment() { 
        FragmentManager fm = getSupportFragmentManager();
        return (ArrivalsListFragment)fm.findFragmentById(android.R.id.content);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentById
  @Override 
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
 
    FragmentManager fm = getSupportFragmentManager();
    if(fm.findFragmentById(android.R.id.content) == null){
      ArtistSearchFragment searchFrag = new ArtistSearchFragment();
      fm.beginTransaction().add(android.R.id.content, searchFrag).commit();
    } 
  } 
 
  /* 
  //Maybe later we'll allow them to switch up the artist 
  protected void onNewIntent(Intent intent){ 
    Log.d(TAG, "In on new intent"); 
    if(Intent.ACTION_SEARCH.equals(intent.getAction())){ 
      String searchQuery = intent.getStringExtra(SearchManager.QUERY); 
      getIntent().putExtra(SearchManager.QUERY, searchQuery); 
      getSupportLoaderManager().restartLoader( 
        SearchFragment.LIB_SEARCH_LOADER_TAG, null, searchFrag); 
6
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentById
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
 
    //TODO before calling fragment, to get ID and give that to it. 
    FragmentManager fm = getSupportFragmentManager();
    if(fm.findFragmentById(android.R.id.content) == null){
      searchFrag = new RegularSearchFragment();
      fm.beginTransaction().add(android.R.id.content, searchFrag).commit();
    } 
  } 
 
  protected void onNewIntent(Intent intent){
    Log.d(TAG, "In on new intent");
    if(Intent.ACTION_SEARCH.equals(intent.getAction())){
      String searchQuery = intent.getStringExtra(SearchManager.QUERY);
      searchQuery = searchQuery.trim();
      getIntent().putExtra(SearchManager.QUERY, searchQuery);
      getSupportLoaderManager().restartLoader( 
        SearchFragment.LIB_SEARCH_LOADER_TAG, null, searchFrag);
    } 
6
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentById
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FragmentManager fm = getSupportFragmentManager();
         
        Fragment f = fm.findFragmentById(android.R.id.content);
        if (f == null) {
            FragmentTransaction ft = fm.beginTransaction();
            ft.replace(android.R.id.content, Fragment.instantiate(this, UpdateStatusFragment.class.getName()), sPostFragmentTag);
            ft.commit();
		} 
    } 
     
    private UpdateStatusFragment getPostFragment() { 
    	return (UpdateStatusFragment) getSupportFragmentManager().findFragmentByTag(sPostFragmentTag);
    } 
 
    private ImagePickerFragment getImagePickerFragment() { 
    	return (ImagePickerFragment) getSupportFragmentManager().findFragmentByTag(UpdateStatusFragment.TAG_PICKER); 
    } 
5
CodeRank
This code example shows how to use the following methods:beginTransaction, findFragmentById
		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) {
			PluginFragment list = new PluginFragment();
			fm.beginTransaction().replace(android.R.id.content, list).commit();
		} 
	} 
 
} 
5
CodeRank
findFragmentById Method Overview
Finds a fragment that was identified by the given id either when inflated from XML or as the container ID when added in a transaction.
See Code Examples for other Android FragmentManager Methods: