使用 TabHost 和 TabWidget 我在 android 中创建了两个选项卡,第二个选项卡的问题是它必须显示带有图像的 ListView 。 所以我使用了这里给出的想法 http://wptrafficanalyzer.in/blog/listview-with-images-and-text-using-simple-adapter-in-android/
所以我的 tab2 指的是该链接中给出的 mail.xml。我如何从 tab2 调用 mainactivity.java 以便显示列表的内容?
.//tab 1 contents
.
TabSpec spec2 = tabHost.newTabSpec("Categories");
spec2.setIndicator("Categories",
getResources().getDrawable(R.drawable.ic_menu_categories));
spec2.setContent(R.id.main);
.
.
在这里,我需要使用一个简单的适配器调用创建该 ListView 的类。我怎么做? 请回复
最佳答案
通过膨胀布局
充气
不知道你使用的是哪种布局
LayoutInflater inflate = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflate.inflate(R.id.main, null);
现在你可以在选项卡中将其设置为 contentView
spec2.setContent(view);
关于android - 在android中设置选项卡的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14069361/