Example usage for android.support.v4.app FragmentManager findFragmentById

List of usage examples for android.support.v4.app FragmentManager findFragmentById

Introduction

In this page you can find the example usage for android.support.v4.app FragmentManager findFragmentById.

Prototype

public abstract Fragment findFragmentById(int id);

Source Link

Document

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.

Usage

From source file:com.heneryh.aquanotes.ui.tablet.SessionsMultiPaneActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sessions);

    Intent intent = new Intent();
    intent.setData(AquaNotesDbContract.Tracks.CONTENT_URI);
    intent.putExtra(TracksFragment.EXTRA_NEXT_TYPE, TracksFragment.NEXT_TYPE_SESSIONS);

    final FragmentManager fm = getSupportFragmentManager();
    mTracksDropdownFragment = (TracksDropdownFragment) fm.findFragmentById(R.id.fragment_tracks_dropdown);
    mTracksDropdownFragment.reloadFromArguments(intentToFragmentArguments(intent));
}

From source file:com.java_lang_programming.android_recycleview_demo.ui.FooterRecyclerViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_footer_recycler_view);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//  w w  w.ja v  a2  s .c o  m

    FragmentManager fragmentManager = getSupportFragmentManager();
    recyclerViewFragment = (FooterRecyclerViewFragment) fragmentManager.findFragmentById(R.id.fragment);
}

From source file:com.heneryh.aquanotes.ui.tablet.VendorsMultiPaneActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vendors);

    Intent intent = new Intent();
    intent.setData(AquaNotesDbContract.Tracks.CONTENT_URI);
    intent.putExtra(TracksFragment.EXTRA_NEXT_TYPE, TracksFragment.NEXT_TYPE_VENDORS);

    final FragmentManager fm = getSupportFragmentManager();
    mTracksDropdownFragment = (TracksDropdownFragment) fm.findFragmentById(R.id.fragment_tracks_dropdown);
    mTracksDropdownFragment.reloadFromArguments(intentToFragmentArguments(intent));
}

From source file:can.yrt.onebusaway.RouteInfoActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    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) {
        RouteInfoListFragment list = new RouteInfoListFragment();
        list.setArguments(FragmentUtils.getIntentArgs(getIntent()));

        fm.beginTransaction().add(android.R.id.content, list).commit();
    }/*from   w  w w. ja  v  a 2s  . com*/
}

From source file:com.commonsware.android.feedfrags.AbstractFeedsActivity.java

public void onItemSelected(RSSItem item) {
    FragmentManager fragMgr = getSupportFragmentManager();
    ContentFragment content = (ContentFragment) fragMgr.findFragmentById(R.id.third_pane);
    FragmentTransaction xaction = fragMgr.beginTransaction();

    if (content == null || content.isRemoving()) {
        content = new ContentFragment(item.getLink().toString());

        xaction.add(R.id.third_pane, content).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .addToBackStack(null).commit();
    } else {// www .  j  a v a2 s . com
        content.loadUrl(item.getLink().toString());
    }
}

From source file:com.rstar.mobile.thermocouple.ui.activities.ToolActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Savelog.d(TAG, debug, "onCreate()");

    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setLogo(R.mipmap.logo_thermocouple);
    getSupportActionBar().setDisplayUseLogoEnabled(true);

    setContentView(R.layout.activity_container);

    int computeType = getIntent().getIntExtra(EXTRA_task, task_default);

    fragmentId = R.id.activityContainer_id;

    FragmentManager fm = getSupportFragmentManager();

    mFragment = fm.findFragmentById(fragmentId);
    if (mFragment == null) {
        if (computeType == task_circuit)
            mFragment = CircuitFragment.newInstance(DefaultTypeCode);
        else if (computeType == task_formula)
            mFragment = FormulaFragment.newInstance(DefaultTypeCode);
        else if (computeType == task_graph)
            mFragment = GraphFragment.newInstance(DefaultTypeCode);
        else if (computeType == task_seebeck)
            mFragment = SeebeckFragment.newInstance(DefaultTypeCode);
        if (computeType == task_sourcecode)
            mFragment = SourcecodeFragment.newInstance(Sourcecode.defaultIndex);
        else if (computeType == task_database)
            mFragment = DatabaseFragment.newInstance(DefaultTypeCode);
        else if (computeType == task_quickconvert)
            mFragment = QuickConvertFragment.newInstance(DefaultTypeCode);

        if (mFragment != null)
            fm.beginTransaction().add(fragmentId, mFragment).commit();
    }//  w  w w .ja v a 2s.c o m
}

From source file:com.slx.funstream.ui.streams.StreamsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_streams);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);//ww w  .ja  v  a2 s .  c o  m
    //getSupportActionBar().setIcon(R.mipmap.ic_launcher);

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.container);

    if (fragment == null) {
        fragment = StreamsContainerFragment.newInstance();
        fm.beginTransaction().add(R.id.container, fragment).commit();
    }
}

From source file:com.commonsware.android.feedfrags.FeedsNavActivity.java

private void removeFragments(FragmentManager fragMgr, FragmentTransaction xaction) {
    ItemsFragment items = (ItemsFragment) fragMgr.findFragmentById(R.id.second_pane);

    if (items != null) {
        xaction.remove(items);/*from   w  w  w . j  av  a  2  s.co  m*/

        ContentFragment content = (ContentFragment) fragMgr.findFragmentById(R.id.third_pane);

        if (content != null && !content.isRemoving()) {
            xaction.remove(content);
            fragMgr.popBackStack();
        }
    }
}

From source file:can.yrt.onebusaway.RegionsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    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) {
        RegionsFragment list = new RegionsFragment();
        //list.setArguments(getIntent().getExtras());

        fm.beginTransaction().add(android.R.id.content, list).commit();
    }/*from   w  w w.  j  av a 2  s  .c  om*/
}

From source file:com.actionbarsherlock.sample.demos.app.FragmentHideShowSupport.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_hide_show_support);

    // The content view embeds two fragments; now retrieve them and attach
    // their "hide" button.
    FragmentManager fm = getSupportFragmentManager();
    addShowHideListener(R.id.frag1hide, fm.findFragmentById(R.id.fragment1));
    addShowHideListener(R.id.frag2hide, fm.findFragmentById(R.id.fragment2));
}