Following tab layout android example on developer website & trying to add a fourth tab
I've managed to get the tab layout example working with the three tabs, albums, songs & artists thanks to other posts on thi开发者_C百科s site. I'm simply trying to add a new tab called, lyrics, following the same procedure by doing the following...
Adding new activity/class called LyricsActivity.....
public class LyricsActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("This is the Lyrics tab");
setContentView(textview);
} }
And then adding the following to the AndroidManifest file....
What happens is that the new Lyrics tab comes up correctly but the text, 'This is the Lyrics tab' does not display, instead it says 'This is the Songs tab'. Any ideas?
Thanks
SD
I think what you probably did was forgot to assign the correct intent to the tab.
// Do the same for the other tabs
intent = new Intent().setClass(this, AlbumsActivity.class);
spec = tabHost.newTabSpec("albums").setIndicator("Albums",
res.getDrawable(R.drawable.ic_tab_albums))
.setContent(intent);
mTabHost.addTab(spec);
Where AlbumsActivity would be your LyricsActivity and so on.
Guide
精彩评论