Code example for FragmentManager

Methods: beginTransaction, findFragmentById

0
        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) {
            TrackListFragment list = new TrackListFragment();
            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 TrackViewHolder { 
 
        TextView artist;
        TextView title;
        ImageView cover;
    } 
 
    // Custom list view item (cover image | artist/album text) 
    public static class TrackCursorAdapter extends SimpleCursorAdapter implements SectionIndexer {