I am working with two fragments in Android Honeycomb (Tab). In the left is a ListView and in the right is a preview of the item selected from the list. When one of the buttons is clicked, I want to show different layouts on the left. How is it possible?
Thanks in advance.
You can do this, I made the same thing with use of these links, here is my code which I am sharing with you in the hope that it will be helpful for you… You will first have to create 4 layouts. 2 of which will be for landscape mode, one for portrait mode and another for tablets. You have to create a couple more folders for layouts and their name should be like
layout-xlargeandlayout-xlarge-port, this way you can create fragments for both mobile devices and tablets.MasterFragment Activity:
Second Activity – DetailFragment Activity:
Now you have to create a third activity,
MasterGridActivityfor my images which I am using for showing in fragment inGridView.Now here is my image adapter –
MyAdapter– for my images which extends aBaseAdapter.Now I am sharing the XML files for these fragments.
Main.xml
gridview.xml
detail_fragment.xml: This XML is for showing the detail in another fragment.
detail_act.xml
Make the same XML for landscape mode and for tablets. It’s working fine for me. Hope it will helpful for you.