Skip to content Skip to sidebar Skip to footer

Android Honeycomb, Get Instance Of Fragments?

I have a PreferenceActivity that loads two Fragments via the xml file for the headers. I don't seem to be able to set a tag or an ID. or a tag for the fragments in the header xml (

Solution 1:

I don't think preference fragments loaded via XML are given a tag, and AFAIK they don't have a known ID, so the only way to do this may be to (1) maintain a separate List<WeakReference<Fragment>> in your PreferenceActivity and add to that list in the Activity's onAttachFragment and (2) later on, look in that list when you need to find a particular fragment.

Solution 2:

Did you manage to do that?

Just did so using the line:

Fragmentshown= getSupportFragmentManager().findFragmentById(R.id.frgHome);

Post a Comment for "Android Honeycomb, Get Instance Of Fragments?"