Depreciation App: Demo of tabs
Choose Tabbed Activity instead of usual Empty Activity
Choose Navigation Style: Action Bar Tabs
So far: moves from tab to tab – has email icon “floating” on each tab
To eliminate the floating button, find it in Layout and delete it
Find the floating button code in MainActivity and delete it as well
And voila – no pink email floating button thing
Right click on layout, choose new Layout resource
Name your new layout resource
For now just add something that will distinguish it from the automatic tab layout fragments
Add new java class: right click one level above MainActivity
Name your class
Add that the class “extends Fragment” and import Fragment I imported the wrong version of Fragment and lost a lot of time
Right click and choose generate
Choose Override methods
Choose onCreateView
Use the inflater and connect to the desired layout you made previously
Go to res/values/strings.xml and change the tab names
Go to MainActivity, the getCount method determines the number of tabs
The tabs in activity_main The tabs in activity_main.xml – but the text of the tabs is controlled by the strings.xml data
Adapt code to send user to your class when first tab is pressed
Result
In Fragment inflate the view but don’t return it right away instead to usual interface code You cannot simply have findViewById() Now it’s myView.findViewById()