On my Android application I am customizing the ActionBar following tips from the android developer blog and other places. I would like to be able to highlight a specific menu item on the ActionBar e.g. with a different background color because it is especially applicable to a currently visible fragment (which actually added it). However I have not found any indication that this can be done nor have I managed to do so myself yet. Is it possible? If so how?
相关问题
- 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
So I got this to work now with a bit of a trick to it. Here goes the fragment code
The main gotcha is that the onclicklistener has to be set on the view that you set as action view and not the menu item for it to work. This way you can do whatever you like.
Also note that you can NOT use getActionView to retrieve the originally set view with title because it will return null. It seem to be more of an alternative view than the actual view for default menu items..