简体   繁体   中英

How can I detect tab focus changes in an android TabLayout?

I have a ViewPager set up with a TabLayout at the top. The app is running on a device with physical d-pad directional keys that can be used to move the control focus.

How can I detect when the focus is moved to specific tabs in the TabLayout? I can see the Tab highlight when the focus is received, but I am unable to find any events that might allow me to detect this. Also, TabSelected doesn't work, as it doesn't fire until the center key of the d-pad is pressed to "select" the focused tab.

You can add custom view to your tab, and then setOnFocusChangeListener for this view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM