Trying to create 2 tabs for TabHost widget. Tabs are created, but they are without names:
Code
package com.samples.tabhost; import android.app.Activity; import android.os.Bundle; import android.widget.TabHost; public class TabHostActivity extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); TabHost tabs=(TabHost)findViewById(R.id.tabhost); tabs.setup(); TabHost.TabSpec spec=tabs.newTabSpec("tag1"); spec.setContent(R.id.tabPage1); spec.setIndicator("Document 1"); // Указал название 1 вкладки tabs.addTab(spec); spec=tabs.newTabSpec("tag2"); spec.setContent(R.id.tabPage2); spec.setIndicator("Document 2"); // Указал название 2 вкладки tabs.addTab(spec); tabs.setCurrentTab(0); } }
Markup file:
<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingTop="62px"> <EditText android:id="@+id/tabPage1" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <EditText android:id="@+id/tabPage2" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </FrameLayout> </TabHost>