Is there a way to detect the user tapping on a tab button in a TabWidget?
I know about OnTabChangeListener, but I want to detect the tap on a tab button even if that tab was already selected.
This is needed to copy a behavior that is standard with iOS. Take for instance the App Store App: Choose the “Categories” tab. Navigate a few levels deep into the categories. Then tap again on the “Categories” tab. This will bring you back to the top level. (as an alternative to tapping multiple times on the back button). I find this very intuitive and therefore also applicable to Android.
This question was asked before: Android Tab Button: handle tap/click event. However the accepted answer there is not useful.
I tried OnClickListener and OnTouchListeners on the TabWidget. But they are never triggered.
Hide the tab widget and use standard buttons to switch between tabs. You can switch tabs using
You can make the button look selected by using the State drawable and setting the button as selected.
Well, to do your requirement, you can put the appropriate code in the buttons onClick listener. This project might give you an idea on setting up the tabs.