1

タブを動的に追加しました。いつも私の最初のタブは、他のタブに行ったり来たりした後にのみロードされます。この問題を解決するための解決策を教えてください。

//------------タブを動的に追加します

    for (int i=0; i<tabs.length; i++){
        String tabName = tabs[i];
        specs = th.newTabSpec(tabName);
        specs.setContent(R.id.llItemList);
        list1=(ListView)findViewById(R.id.lvCommonList);
        adapter=new Adapter(this, item[i]); 
        list1.setAdapter(adapter);
        specs.setIndicator(tabName);
        th.addTab(specs);
    }   

public void onTabChanged(String tabId) {
    // TODO Auto-generated method stub
       currentTab =  tabId; 
         for (int i=0; i<tabs.length; i++){
        if (currentTab.equals(tabs[i])){ 
            linearLayout.removeView(list1);
            linearLayout.addView(list1);
            adapter=new Adapter(this, item[i]);  
            list1.setAdapter(adapter);
        }
    }
} 
4

0 に答える 0