I’m learning developing for android but i don’t know how to create the UI for a Fragment.
I created a new activity and during the creation process I selected the navigation type “Tabs + Swipe”.
Now i have a layout xml which i can’t modify using the WYSIWYG interface and if i -for example- create a button widget using java in the class file it creates it in every “tab view”.
I basically want to create different interfaces for every tab (fragment).
Thank you
In just created Activity you can find inner class
SectionsPagerAdapter. Look at this method:This method for every tab returns instance of DummySectionFragment with only different bundles. If you want to create fragments with different views for every tab you should check value of
ivariable and according to this value create proper fragment. For example:Instead of
DummySectionFragmentclass create three classes: MyFragment1, MyFragment2, MyFragment2 and for each, inside methodonCreateViewcreate or inflate view, for example:}
Where R.layout.my_fragment1.xml is layout of your MyFragment1 fragment.