0

TextViewを含むカスタムレイアウトを持つTabがあります。 後でそのテキストを実際のタブの子から更新する必要があります。ここでカスタムタブのテキストを編集する

が、私は今...私はそれを設定する方法があり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"); 

しかし、私はカスタムタブを必要とする:)

誰もが任意のアイデアや提案を持っていなかった場合、次は動作しますか? ありがとう

答えて

0

これで分かりました。

protected void updateText(int key, String text) { 
    View view = mTabHost.getCurrentTabView(); 
    TextView tv = (TextView) view.findViewById(R.id.tabsText); 
    tv.setText(text);  
} 

そして、私の子タブで、私はこの呼び出し:

((MyTabActivity)getParent()).updateText(((TabActivity)getParent()).getTabHost().getCurrentTab(), "The new text"); 

をそして今、あなたは:)

を知っている私は、このメソッドを持っている TabActivity

関連する問題