In the previous example:
Import android. app. tabactivity; import android. content. intent; import android. OS. bundle; import android. widget. tabhost; import android. widget. tabhost. tabspec; public class mainactivity extends tabactivity {@ overrideprotected void oncreate (bundle savedinstancestate) {// todo auto-generated method stubsuper. oncreate (savedinstancestate); setcontentview (R. layout. main); // obtain the tabhost object tabhost = gettabhost (); // Add the tag intent = new intent (mainactivity. this, musiclistactivity. class); tabspec tabspecmusic = tabhost. newtabspec ("Music "). setcontent (intent); tabspecmusic. setindicator ("Music", getresources (). getdrawable (R. drawable. music); tabhost. addtab (tabspecmusic); tabspec tabspecalbum = tabhost. newtabspec ("album "). setcontent (intent); tabspecalbum. setindicator ("album", getresources (). getdrawable (R. drawable. album); tabhost. addtab (tabspecalbum); tabspec tabspecartist = tabhost. newtabspec ("aritist "). setcontent (intent); tabspecartist. setindicator ("artist", getresources (). getdrawable (R. drawable. ITEM); tabhost. addtab (tabspecartist); tabspec tabspeclast = tabhost. newtabspec ("last "). setcontent (intent); tabspeclast. setindicator ("Recent playback", getresources (). getdrawable (R. drawable. last); tabhost. addtab (tabspeclast); // you can specify which tab tabhost is currently displayed. setcurrenttab (0 );}}
In addition, there must be a musiclistactivity, which can be empty, but must be empty. Otherwise, the four new icons are hidden. Because the area below the icon stores items in the corresponding acticity, it can be blank, but it cannot be left blank !!!
import android.app.ListActivity;public class MusicListActivity extends ListActivity{ }
Result chart:
This article only provides a very simple column, and four specific activities corresponding to the four icons have not been written yet. However, it will be provided in the subsequent code ~~~ You are welcome to come up with good ideas for Android ~~~