Code example for FragmentManager

Methods: beginTransaction, findFragmentById

1
        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;