android - 哪个选项卡更好?

标签 android android-listview android-tabhost

我已经阅读了带有 Activity 和 View 的选项卡的不同示例。我知道每个都有一定的局限性。目前我想知道哪个是解决我的问题的更好选择。我有 4 个选项卡,每个选项卡都有相同的 ListView ,但每个列表的内容会不同。

我尝试了以下方法: 创建选项卡 Activity 并为列表设置单一 Activity ,并为每个具有不同内容的选项卡加载相同的列表。不知何故,这似乎不是正确的方法。

帮我找到一个好的方法。谢谢 快乐编码!!

最佳答案

对不同的标签使用不同的 Activity 。像这样:

intent = new Intent().setClass(Tabhost.this, ArtistsActivity.class);

// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("artists").setIndicator("Artists",
                  res.getDrawable(R.drawable.ic_tab_artists))
              .setContent(intent);
tabHost.addTab(spec);

看看android developer site .

关于android - 哪个选项卡更好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9224249/

相关文章:

android - 当在 actionBar 上按下后退按钮时,不会调用 onOptionsItemSelected

android - 如何在线程内用 Toasts 替换 system.out

android - RelativeLayout 中的 EditField 有输入滞后

android - Tab 内具有 CanGoBack 功能的当前 webview

java - 使用 FragmentPagerAdapter 从 Fragment 以编程方式更改选项卡

android - 使用 fragment 时如何正确实现状态栏后面的 View 内容

java - 无法启动 Activity ComponentInfo {com.example.list/com.example.list.editbox} : java. lang.NullPointerException

android - 同样的老故事 : OnItemClickListener just not working

android - 如果自定义 ListView 行内容是动态的,如何使用 View 持有者?

android - 如何在底部的android中设计一个类似iPhone的菜单/按钮?