1

2 つのリストを表示する 2 つのタブを持つ TabActivity があります。tabHost.getTabWidget().getChildCount() を使用して、タブ インジケーターを動的に変更しました。ただし、アプリケーションの起動中、getChildCount は 2 ではなく 1 を返します。

私を助けてください..

ここにコードを添付しています..

 @Override
public void onTabChanged( String arg0 )
{
    if ( LIST1_TAB_TAG == tabHost.getCurrentTabTag() )
    {
        ImageView iv = (ImageView)tabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.icon);
        iv.setImageDrawable(res.getDrawable(R.drawable.rupees));
        Log.v( "check", "onTabChanged :: ChildCount == " + tabHost.getTabWidget().getChildCount() );

    }
4

2 に答える 2

2

getChildCount()クラスから継承されたメソッドViewGroupであり、タブウィジェットの使用でタブビューをループするタブウィジェットのタブの数とは何の関係もないと思います

タブ アクティビティのコンテキストで

for (int tabIndex = 0 ; tabIndex < getTabWidget().getTabCount() ; tabIndex ++)
{
   View tab getTabWidget().getChildTabViewAt(tabIndex);
}

TabHost を使用した通常のアクティビティの場合

yourTabhostVariable.getTabWidget()
于 2012-07-23T10:26:49.060 に答える