2

I have this app with a common activity and several different fragments replaced into the same layout ID: R.id.content

Some of the fragments are normal support.v4.Fragment and some are from v4.DialogFragment

On tablets, DialogFragments are shown as Dialogs and on phones they're normally included in the R.id.content

So usually if I want to find out which fragment is current, it's easy to call

getSupportFragmentManager().findFragmentById(R.id.content);

but the DialogFragments issued are Dialogs are not on the R.id.content, AFAIK they're not even in the same Window.

So the question is: is there any "framework level" way to locate the dialog fragments? I mean, is there a way to do it without having to manually keeping reference of Fragments (or their tags) ?

Budius
  • 39,391
  • 16
  • 102
  • 144
  • Why isn't the tag enough? – Sherif elKhatib Oct 02 '13 at 13:16
  • because I'm already using tag to identify type and ID of content. A third layer or information in a single string would complicate stuff even more. – Budius Oct 02 '13 at 13:38
  • May I know do you mean identify type and ID? – Sherif elKhatib Oct 02 '13 at 13:54
  • type: photo, photo stream, content stream, user profile, comments page, like page, etc. ID: a number – Budius Oct 02 '13 at 14:46
  • You could create an interface that provides this data and let all your fragments (using a base fragment) implement this interface and probably make these stuff more systematic. – Sherif elKhatib Oct 02 '13 at 14:59
  • But the reason they're in the tag is so I can use findFragmentByTag to locate specific fragments on my stack. And I'm sorry, do you have an answer to the actual question? Even if it's "it's not possible" ? – Budius Oct 02 '13 at 15:07

0 Answers0