Skip to content Skip to sidebar Skip to footer

How Can I Open My Fragment Class In A New Intent?

How can i open my fragment class in a new intent? i know fragments cannot be opened by a activity. How do i fix this? i want to know how i can put my fragment class into a activity

Solution 1:

you have to use FragmentManager

    android.support.v4.app.Fragmentdetail=newDetailFragment();
    android.support.v4.app.FragmentManagerfragmentManager= getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, detail).commit();

Solution 2:

Fragments aren't called through intents, but through the FragmentManager. Check out http://developer.android.com/guide/components/fragments.html.

Post a Comment for "How Can I Open My Fragment Class In A New Intent?"