Skip to content Skip to sidebar Skip to footer

Show Different Layouts In Fragmentation

I have a problem that I want to load different layouts every time in a fragment when a list Item is clicked from different fragment. Means I have two fragments on a screen, first o

Solution 1:

You would probably be better off (cleaner design) if you used separate Fragments for the different data types you are presenting. This will keep your Fragments cleaner and the Activity can just create the appropriate Fragment and replace the previous one in the container view. However, if you really want to do it the way you describe, you can pass a "mode" to the Fragment via its argument Bundle and the Fragment can use that information to inflate the appropriate layout file and logic.

See this developer guide for details and examples with using arguments and fragments: http://developer.android.com/training/basics/fragments/fragment-ui.html

Post a Comment for "Show Different Layouts In Fragmentation"