2

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 (that is loaded using loadHeaderFromResource();

Since I don't instantiate it myself I have no ID. or reference to get hold of it.

What do I do?

Programmer Bruce
  • 64,977
  • 7
  • 99
  • 97
Hamid
  • 4,410
  • 10
  • 43
  • 72

2 Answers2

0

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.

Roman Nurik
  • 29,665
  • 7
  • 84
  • 82
  • Thanks for the reply, in the end I did a complete re-write of my UI implementation so that my fragments are loaded in code by myself so i have a handle on them, this way i have complete control which made life much easier. – Hamid Jul 02 '11 at 18:56
0

Did you manage to do that?

Just did so using the line:

Fragment shown = getSupportFragmentManager().findFragmentById(R.id.frgHome);
RMalke
  • 4,048
  • 29
  • 42
  • There is no ID for the xml loaded fragments which is why i couldn't use this method, in the end I managed the fragments myself. – Hamid Jul 27 '11 at 16:00