У меня есть вкладки в виде представлений в моей деятельности. Каждая вкладка представляет собой ListView
. Чтобы еще больше прояснить ситуацию, ListView
не имеет раздутых TextView
. Поскольку в схеме xml для ListView
нет текстового атрибута, мне было интересно, смогу ли я сделать это внутри своей активности. Если нет, то что бы вы предложили?
файл макета: tabworkentry.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/tablayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Include action bar -->
<include layout="@layout/actionbar_layout"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/innerdashboard_bg"
android:layout_weight="1">
<!-- Top 10 starts -->
<ListView
android:id="@+id/Top_10"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:text="this is a tab" />
<!-- Top 10 ends -->
<!-- Billable starts -->
<ListView
android:id="@+id/Billable"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:text="this is another tab" />
<!-- Billable ends -->
<!-- Product starts -->
<ListView
android:id="@+id/Product"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="5dp"
android:textSize="14sp"
android:text="this is a third tab" />
<!-- Product ends -->
</LinearLayout>
</TabHost>
И код Java:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabworkentry);
TabHost mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("top10").setIndicator("Top 10").setContent(R.id.Top_10));
mTabHost.addTab(mTabHost.newTabSpec("billable").setIndicator("Billable").setContent(R.id.Billable));
mTabHost.addTab(mTabHost.newTabSpec("product").setIndicator("Product").setContent(R.id.Product));
mListView = (ListView)findViewById(R.id.Top_10);
mListView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,Top_10));
mListView = (ListView)findViewById(R.id.Billable);
mListView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,Billable));
mListView = (ListView)findViewById(R.id.Product);
mListView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,Product));
} catch (Exception e) {
System.out.println("Exception" + e.getStackTrace());
Log.d(TAG, "Exception" + e.getStackTrace());
}
}