How to get actionbar views objects?

断了今生、忘了曾经 提交于 2019-12-11 04:19:41

问题


Is there a way that you can get actionbar views as object references. For instance I would like to get the overflow view in order to know the coordinates on the screen. currently I have manage an ugly solution which is. Get a menu item with an id

overflowView =((ViewGroup)parent.findViewById(R.id.menu_id).getParent()).getChildAt(2);


回答1:


Is there a way that you can get actionbar views as object references.

Only the ones you create yourself, via android:actionLayout and kin.

For instance I would like to get the overflow view in order to know the coordinates on the screen.

Your solution is unlikely to remain stable across Android versions. It may or may not work on ActionBarSherlock. I would recommend that you find some other solution for whatever you perceive your problem to be that does not involve messing around with the internals of the ActionBar implementation.



来源:https://stackoverflow.com/questions/11346177/how-to-get-actionbar-views-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!