タブホストタブの名前を自動的に変更するにはどうすればよいですか?
TabHost tmp = (TabHost) findViewById(R.id.tabhost);
tmp.getTabWidget().getChildAt(0).findViewById(android.R.id.title).setText("Test");
SetText(string)
テキストビューでは定義されていません。なぜですか?
ありがとう
タブホストタブの名前を自動的に変更するにはどうすればよいですか?
TabHost tmp = (TabHost) findViewById(R.id.tabhost);
tmp.getTabWidget().getChildAt(0).findViewById(android.R.id.title).setText("Test");
SetText(string)
テキストビューでは定義されていません。なぜですか?
ありがとう
タブのテキストを変更するには、ビュー、つまりタブのタイトルとして設定されているTextViewを取得する必要があり、次のように変更できます。
TabHost tabhost = getTabHost();
for(int i=0;i<tabhost.getTabWidget().getChildCount();i++)
{
TextView tv = (TextView) tabhost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
tv.setText(.....);
}
TabHostの詳細については、このリンクを参照してください http://developer.android.com/reference/android/widget/TabHost.html
LinearLayout rLayout = (LinearLayout) tmp.getTabWidget().getChildAt(Pos_of_ur_tab_in_tab_widget_for_which_text_to_changed);
((TextView)rLayout.getChildAt(position_of_ur_textview_child_in_tab_layout)).setText("your_text");