Android action bar input events

I would like to know if it is possible to detect more accurate input events in the action bar than the selected navigation item.

I would like to be able to detect what the normal view will detect: click, longclick touch, etc ... for all elements in the action bar: icon, menu, etc. Is there an easy way?

+4
source share
1 answer

You can use android:actionLayout or android:actionViewClass so that the menu items of the items turn into any widgets you want, and then you can connect whatever you want from them.

You cannot connect arbitrary listeners to other menu items, whether they are action items or are in the overflow menu. Similarly, you cannot connect arbitrary listeners to anything else in the action bar that is not clearly visible widgets, such as an icon, title, tabs, navigator, etc.

If these are your widgets, you can customize the listeners. If they are not your widgets, you cannot configure listeners.

+2
source

Source: https://habr.com/ru/post/1390956/


All Articles