0
我正在嘗試將TabHost的Tabs文本更改爲文本,使其位於singleLine=true
。要做到這一點,我試圖創建TextView並添加此屬性singleLine
。問題是我不能在TabHost中插入這個TextView。如何更改TabHost標題?
我該怎麼做?
我正在試着這個。
XML TabHost
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0"
android:layout_gravity="bottom">
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
的TextView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:id="@+id/perfil"
android:text="teste de aba para tab host"
/>
</LinearLayout>
活動
public class AreaAlunoMainActivity extends FragmentActivity {
private FragmentTabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.areadoaluno_main);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
mTabHost.addTab(
mTabHost.newTabSpec("perfil").setIndicator("Perfil", null).setContent(R.id.perfil),
PerfilFrag.class, null);
}
}
你需要設置標籤主機與自定義佈局..... – koutuk
@koutuk我該怎麼辦? – FernandoPaiva