Android Can anyone know about Actionbar item options long click , I want to show text on LongClick on actionbar menu option like a hint on long press of actionBar long press
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I think "findViewById" is the easiest way to find.
Just do
user1206890, you do not need listen long click event. If you want show action hint, will be sufficient set title in menu add. Checked on 2.3 and 4.0.
For me, the following approach works fine for newer Android versions - I tested it with Android 4.2 and Android 5.0.1.
The idea is that I replace the action icon view by a custom view. Here, I have to handle the single click, and I can handle the long click.
If I want the appearance to be exactly like normal action bar icons, the following works.
First, create a layout containing just an ImageButton with your icon.
Then put this ImageButton into the action bar and attach listeners to it.
Important remark: this will only work if the item appears in the action bar. So, whatever you want to do on long click will not be accessible in this way if the option appears in the menu dropdown.
If you create your own action view via
android:actionLayout
, you are welcome to set up listeners on your own widgets for long-click events. You do not have access to widgets in the action bar that you do not create yourself.Do you want to capture long press on menu item on action bar? As for me, after finding 2,3 hour, I found this solution. This is perfectly work for me.