I have the following scenario. A tabhost manages four ListFragmnet. For every ListFragment I have several fragment. For instance associated with the ListFragmnet 1 I have the fragments A, B, C and can happens that fragment A "launch" fragment B which can launch fragment C. Is correct to allow fragments to start each other or is there a more correct way?
Thanks
Edit:
TabFragmentActivity:
tab1(ListFragment): fragment 1 -> fragment 2 -> .... -> fragment N
tab2(ListFragment): fragment 1 -> fragment 2 -> .... -> fragment N
tab3(ListFragment): fragment 1 -> fragment 2 -> .... -> fragment N
tab4(ListFragment): fragment 1 -> fragment 2 -> .... -> fragment N
this is want to achieve. So, my question is what is the best way to manage transaction from fragment 1 to fragment N per tab?
Again thanks
The point of having fragments is to separate the logic ! try to think of than like a pieces that doesn't know the existent of anything else except the activity in which they are placed.
how the things should works: -the activity implements interface let say that interface have method startFragmentB(); -than from the fragmentA you can do this ((myInterface)getActivity()).startFragmentB(); -all of the transactions logic should be in the activity -keep reference to all of the fragments in the activity...
this should give you a nice starting point with fragments, if you have any question just ask, i comment, as a general answer to you question:
NO it is not correct from one fragment to start other, everything should go through the activity,YES you can decide if you want to start another fragment or not but you should not do the actual starting there(in the fragment).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With