0

I want to know how to clear child activities and how to invoke the parent activity of a particular tab on its second click (tab functionality like on iPhone?). I want to invoke the click listener for each tab. Assume as if the application gets deeper while using, it's hard to use the back button often to reach the parent activity. So i need to invoke the parent activity by clicking the tab.

On first tab it is working fine, here is the code

getTabWidget().getChildAt(0).setOnClickListener(new OnClickListener() { 
    public void onClick(View v) {      
        if (getTabHost().getCurrentTabTag().equals("gebrauchte")) { 
            Intent intent = new Intent(getApplicationContext(),TabHome.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        } else{                 
            tabs.setCurrentTab(0);  
        }
    }
});

I tried to use the same code for the second tab with getChildAt(1), should i give TabHome class for all intent, if I try to give their respective class of 2nd, 3rd and 4th tab, the tabHost gets hidden.

4

1 回答 1

0

您不需要在选项卡上设置 onClickListener。我建议使用带有 Fragments 的 Android 选项卡

于 2012-07-12T13:32:11.737 回答