how to detecting a click on an already selected tab button

后端 未结 3 1045
既然无缘
既然无缘 2021-01-02 14:21

I am trying to get the Click event when clicking on currently selected tab of my TabActivity.

I tried below code but when i click on one tab the other tabs ar

3条回答
  •  星月不相逢
    2021-01-02 14:56

    I needed to detect second click only for one tab, so this answer worked for me. The trick is setting the OnClick for the child and not for the TabHost itself.

    getTabWidget().getChildAt(0).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i("TAG", "Clicked tab : "+getTabHost().getCurrentTabTag());
            tabHost.setCurrentTab(0);                                    
        }
    });
    

提交回复
热议问题