多亏了本网站上的其他帖子,我已经设法获得了与三个选项卡、专辑、歌曲和艺术家一起使用的选项卡布局示例。我只是想添加一个名为 lyrics 的新选项卡,按照相同的步骤执行以下操作...
添加名为 LyricsActivity 的新 Activity/类......
公共(public)类 LyricsActivity 扩展 Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("This is the Lyrics tab");
setContentView(textview);
}
然后将以下内容添加到 AndroidManifest 文件....
发生的情况是新的歌词选项卡正确出现,但文本“这是歌词选项卡”没有显示,而是显示“这是歌曲选项卡”。有什么想法吗?
谢谢
标准差
最佳答案
我认为您可能是忘记为选项卡分配正确的 Intent 。
// 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);
AlbumsActivity 将是您的 LyricsActivity 等。
关于android - 按照开发人员网站上的选项卡布局 android 示例并尝试添加第四个选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2377095/