Simple use of tabhost for Android music player (2)

Source: Internet
Author: User

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 ~~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.