In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to use menu to display icons and text at the same time in Android", the editor shows you the operation process through actual cases, the operation method is simple and fast, and practical. I hope that this article "how to use menu to display icons and text at the same time in Android" can help you solve the problem.
Realization of displaying Icon and text at the same time by menu in Android
The menu entry in Activity, when setting its showAsAction= "never", displays only the text title by default, not the icon icon. You can override onMenuOpened () in Activity to make the icon visible by reflection.
/ / Let the menu display both the icon and the text @ Overridepublic boolean onMenuOpened (int featureId, Menu menu) {if (menu! = null) {if (menu.getClass (). GetSimpleName (). EqualsIgnoreCase ("MenuBuilder")) {try {Method method = menu.getClass (). GetDeclaredMethod ("setOptionalIconsVisible", Boolean.TYPE); method.setAccessible (true); method.invoke (menu, true) } catch (Exception e) {e.printStackTrace ();} return super.onMenuOpened (featureId, menu);}
Post my menu.xml below
So much for the introduction of "how to use menu to display icons and text at the same time in Android". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.