问题描述:

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? :D

相关阅读:
Top