There are two common methods of tab paging in Android:
I. The combination of tabactivity and tabhost
1. Main class inheritance Tabactivity
public class Tagpage extends tabactivity
2. Get the current Tabhost object
Final Tabhost tabhost = Gettabhost ();
3. Add tab page tab, here is the key to link each page into activity. The jump of the page is the activity's jump.
Tabhost.addtab (Tabhost.newtabspec ("Tab1"). Setindicator ("TaB2", Getresources (). getdrawable (R.DRAWABLE.A1)). SetContent (New Intent (this, page1.class));
Ii. Activitygroup and GridView the combination
1. Main class inheritance Activitygroup
public class Gridviewtabpage extends Activitygroup
2. Get activity view for each sub-page
Intent Intent = new Intent (gridviewtabpage.this, Page1.class);
Subpageview = Getlocalactivitymanager (). StartActivity ("Subpageview" + I, intent);
3. Loading into the container
Pagecontainer.addview (Subpageview Getdecorview (), layoutparams.fill_parent, layoutparams.fill_parent);
If you have too many tab options, you can use the gallery+activitygroup combination of implementations.
1. Single activity Architecture (recommended)
The homepage is activity, the inside page is view, the bottom column of the head is common, just changes the text and the pattern. The bottom navigation bar is RadioButton, the middle can slide to toggle. Jump quickly, but the home page is not smooth.
The benefits of this architecture are clear thinking and low system operating overhead. The downside is poor control, code clutter, and poor lifecycle management.
2. Multiple activity-use baseactivity to provide commonality
3, multiple activity-use tabactivity
Mainactivity (tabactivity), sub-activity (baseactivty)
The code and ideas are clear, baseactivity have the same back and head bottom bar.
3.1 Mainactivity (tabactivity), son activity (Activitygroup), grandson activity (baseactivty)
PS: For jumps that need to implement multiple activity within a tabhost
3.2 RadioButton with tabactivity jump (code very clear)
4, multiple Activity-activitygroup (official has been marked as not recommended)
The bottom bar is implemented with the GridView, with RadioButton at the bottom.
(reprint) Android two tab paging way: Tabactivity and Activitygroup and Android project several common application architectures