On Mon, Mar 28, 2011 at 1:05 PM, Weston Weems <[email protected]> wrote:
> 1) Does a fragment manage knowing anything about an existing fragment
> have anything to do with being able to see the fragment? It would seem
> that regardless of adding/removing/hiding/showing, the fragment was
> always still there.
>
Yes it keeps a list of added fragments, which is unrelated to them being
hidden and shown. These are all of the fragments that are actually actively
in use, so need to have their state saved etc.
> 2) when I add or replace, should I be creating a new instance of that
> fragment, or could I theoretically have instances... (and does the add
> process just "register" it with the fragment manager?
>
You can only have one instance of a fragment added at any time. Note that
if you are removing a fragment in a FragmentTransaction that is being put on
the back stack it is STILL ADDED, because that instance still needs to be
tracked and made active again when that back stack state is popped.
> 3) Am I going about this completely wrong? I still like that the
> separation is there, and that the fragments are decoupled and
> reusable, but doesnt seem like the reuse is actually there.. I cant
> replace an instance of a fragment with another instance if the other
> instance.
>
Unfortunately I wasn't really able to follow your description enough to have
a good answer.
> I have done some research and saw the references to the problem with
> inflating views into parent context or root, and likewise always do my
> inflation with R.layout.whatever,null,false.
>
You should use the same call to inflate() that is shown in the sample code
--
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.hello_world, container, false);
...
return v;
}
--
Dianne Hackborn
Android framework engineer
[email protected]
Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en