をTab
含むカスタムレイアウトを持つがありますTextView
。後で実際のタブの子からそのテキストを更新する必要があります。
これが私がそれを設定する方法ですTabActivity
private void setupTab(final String tag) {
//Call createTabView() to give the tab a layout with some text
View tabview = createTabView(mTabHost.getContext(), tag);
Intent intent = new Intent().setClass(this, MyActivity.class);
TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(intent);
mTabHost.addTab(setContent);
mTabList.add(setContent);
}
private View createTabView(final Context context, final String text) {
View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
TextView tv = (TextView) view.findViewById(R.id.tabsText);
tv.setText(text); //we set the text of the tab here.
LinearLayout tvX = (LinearLayout) view.findViewById(R.id.tabsLayout);
return view;
}
設定方法は次のとおりです...子タブのアクティビティで、テキストを更新する必要があります...カスタムタブがない場合は、次のように機能すると思います...
((TabActivity)getParent()).getTabHost().setTag(((TabActivity)getParent()).getTabHost().getCurrentTab(), "new text");
しかし、カスタムタブが必要です:)
誰かアイデアや提案はありますか?ありがとう