[英]Android: Tab Content not appearing
I have an info tab, which should have a listview, imageview and textview. 我有一个信息选项卡,其中应该有一个列表视图,图像视图和文本视图。 For some reason the content is not showing. 由于某种原因,内容未显示。 Here is the code I use to set the tab up. 这是我用来设置标签页的代码。
tabHost.addTab(tabHost.newTabSpec("tab4")
.setContent(R.id.layout_tab_four).setIndicator(tabname4,res.getDrawable(R.drawable.information)));
Here is the layout file: 这是布局文件:
<ViewFlipper android:id="@+id/layout_tab_four"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_width="wrap_content" android:id="@+id/infologo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_height="wrap_content" />
<ListView android:layout_width="match_parent" android:id="@+id/infolistview"
android:layout_height="20dp" android:layout_weight="1"
android:layout_alignParentLeft="true" />
<TextView android:layout_width="wrap_content" android:text="General"
android:id="@+id/textView1" android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" />
</ViewFlipper>
Thanks in advance 提前致谢
EDIT: 编辑:
List View Code: 列表查看代码:
infoList = (ListView) findViewById(R.id.infolistview);
infoListAdapter = new ArrayAdapter(this, R.layout.item,
this.fetchInfoList());
infoList.setAdapter(infoListAdapter);
Fetch Info List Method: 获取信息列表方法:
public ArrayList<String> fetchInfoList() {
ArrayList<String> listItems = new ArrayList<String>();
String listItem9 = "Visit Our Website";
listItems.add(listItem9);
return listItems;
}
use for select your tab this (after setting the content like you did): 用于选择选项卡(在像您一样设置内容之后):
tabHost.setCurrentTab(X);
Where -1 < X < (numberoftabs -1) //Do you like maths? -1 <X <(numberoftabs -1) //您喜欢数学吗? :D :D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.