In the Android mobile app layout, QQ client tab bar, Sina Weibo homepage, etc. with the tabactivity layout can be easily switch activity. During the winter vacation, in the simulation of the QQ client tab bar Layout development, the first attempt to tabactivity development.
The program realizes "friends", "discussion group", "group" three sub-activity interface, call three activities in Tabactivity, with "group" activity as Welcome page, tabactivity code as follows:
1 Public classMainactivityextendstabactivity {2 3 @Override4 Public voidonCreate (Bundle savedinstancestate) {5 Super. OnCreate (savedinstancestate);6 Setcontentview (r.layout.activity_main);7 8Tabhost Tabhost =gettabhost ();9 Tabhost.tabspec spec;Ten Intent i; One AI=NewIntent ( This, Myfriendactivity.class); -Spec=tabhost.newtabspec ("1"). Setindicator ("Friends"). SetContent (i); - Tabhost.addtab (spec); the -I=NewIntent ( This, Mygroupactivity.class); -Spec=tabhost.newtabspec ("2"). Setindicator ("group")). SetContent (i); - Tabhost.addtab (spec); + -I=NewIntent ( This, Mydiscussionactivity.class); +Spec=tabhost.newtabspec ("0"). Setindicator ("discussion group")). SetContent (i); A Tabhost.addtab (spec); atTabhost.setcurrenttab (1); - } -}
Run the program with a "program terminated" prompt.
After Baidu search, found in the androidmanifest.xml lack of "Group", "Friend", "dicussion" the configuration of the activity. The original idea was to invoke these activities with tabactivity, without having to configure them. The configuration code for the child activity is as follows:
1 <activity2 android:name= "com.example.qq.MyDiscussionActivity" >3 </activity>4 5 <6 android:name= "Com.example.qq.MyFriendActivit"/>7 8 <activity9 android:name= "com.example.qq.MyGroupActivity"/>
The results of the final normal operation are as follows:
Software Test Job 1:android mobile app layout tabactivity