Mark M. | has entered the room |
Oct 17 | 7:25 PM |
Mark M. | turned on guest access |
ry | has entered the room |
Mark M. |
hello, ry!
|
Mark M. |
how can I help you today?
|
ry |
Hi mark
|
ry |
I just have some questions relating to my app
|
Oct 17 | 7:30 PM |
ry |
I'm trying to extend the model fragment architecture from the tutorial
|
ry |
And i'm wondering if that's the best way to do it... because I have multiple screens which need to access its own instance of the model fragment
|
Mark M. |
well, a model fragment is designed to help manage the model objects for one activity
|
Mark M. |
you can say that you have several activities sharing the same model fragment class
|
ry |
Yes, same class, but its own instance of each model fragment
|
Mark M. |
however, if they are all working off of the same model objects, that begs the question of why they are separate activities in the first place
|
Mark M. |
I would typically expect different activities to need different model fragment classes, just because they would be working with different facets of your overall data
|
ry |
I want to enable the back button for users
|
ry |
and they are fragments not activities
|
Mark M. |
ah, sorry -- when you wrote "multiple screens", I inferred that you meant multiple activities
|
ry |
so the user can go to a new screen, which is the same activity but different fragments, and i want each fragment to have its own model fragment instance
|
Mark M. |
um, I don't know how you are going to do that
|
ry |
it all feels a bit messy... i'm not sure if this is a good way
|
Mark M. |
the reason for a model fragment is to centralize activity-level things like configuration changes
|
Oct 17 | 7:35 PM |
Mark M. |
off the cuff, I have not really thought about trying to have a model fragment per fragment in a multi-fragment activity
|
Oct 17 | 7:35 PM |
Mark M. |
I suppose there is nothing stopping you from doing that, so long as you can keep track of unique tags for each model fragment instance
|
Mark M. |
I'm not completely certain what you're gaining over having a single model fragment that happens to hold distinct portions of data for the active fragments
|
ry |
hmm... yea. youre right, i just need the model fragment to hold an arraylist for each fragment. so i could just put all those arrays in one model fragment instance
|
Mark M. |
right
|
ry |
i'm also having trouble using findfragmentbytag inside of a fragment to get the instance of the model fragment that i've created in the activity. do you know off the top of your head if there's a common mistake i'm making?
|
Mark M. |
are you using nested fragments (e.g., getChildFragmentManager())?
|
Mark M. |
if yes, your model fragment is probably in the activity's FragmentManager, not one of the fragment's child FragmentManagers
|
Oct 17 | 7:40 PM |
ry |
all the fragments are created by that one activity, and i'm using getsupportfragmentmanager in my activity and in my fragments
|
Mark M. |
then, off the cuff, I'm not sure what might be causing lookup problems, sorry
|
ry |
ok, i'll keep trying to debug it
|
ry |
thank you for the help
|
Mark M. |
you are very welcome
|
ry | has left the room |
Oct 17 | 8:30 PM |
Mark M. | turned off guest access |