【发布时间】:2012-04-30 21:51:34
【问题描述】:
我编写了一个在运行时生成图库的方法。
private Gallery createGallery(ImageAdapter imageAdapter) {
Gallery sampleGallery = new Gallery(getApplicationContext());
sampleGallery.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
sampleGallery.setGravity(Gravity.FILL_VERTICAL);
sampleGallery.setSpacing(5);
sampleGallery.setAdapter(imageAdapter);
sampleGallery.setSelection(1);
return sampleGallery;
}
然后我创建一个厨房并尝试将其设置为选项卡布局。
final TabHost mTabHost = (TabHost) findViewById(R.id.tabHost);
mTabHost.setup();
Gallery tabGallery = createGallery(brkingNewAdapter); // my image adapter
tabGallery.setId(R.id.gallery_1);
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1")
.setContent(R.id.gallery_1));
R.id.gallery_1 被定义为here 中的提及。
我得到一个异常如下。
无法创建标签内容,因为找不到 ID 为 2130968576 的视图
有什么帮助吗?
提前谢谢你。
【问题讨论】:
标签: android android-layout tabs