我已经反编译了一些代码,并且试图找出与常量值一起出现的常量名称.在我的一个xml文件中,我看到了app:showAsAction =“ 2”.看起来像是according android,它可以取值“ ifRoom” | “从不” | “ withText” | “总是” | “ collapseActionVIEw”但是我如何找出哪一个呢?有时我可以在网上找到对常量值-名称映射的引用,但有时却找不到.有办法确定吗?
<?xml version="1.0" enCoding="utf-8"?><menu xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto"> <item androID:icon="@drawable/my_drawable" androID:enabled="false" androID:title="my Title" app:showAsAction="2"></item></menu>
解决方法:
你当然可以,
您需要查看androID.vIEw.MenuItem的源代码.在那里定义了许多常量,包括您需要的常量.
public static final int SHOW_AS_ACTION_ALWAYS = 2;
这是androID.vIEw.MenuItem接口的来源,
public interface MenuItem { /* * These should be kept in sync with attrs.xml enum constants for showAsAction */ /** Never show this item as a button in an Action bar. */ public static final int SHOW_AS_ACTION_NEVER = 0; /** Show this item as a button in an Action bar if the system decIDes there is room for it. */ public static final int SHOW_AS_ACTION_IF_ROOM = 1; /** * Always show this item as a button in an Action bar. * Use sparingly! If too many items are set to always show in the Action bar it can * crowd the Action bar and degrade the user experIEnce on devices with smaller screens. * A good rule of thumb is to have no more than 2 items set to always show at a time. */ public static final int SHOW_AS_ACTION_ALWAYS = 2; /** * When this item is in the action bar, always show it with a text label even if * it also has an icon specifIEd. */ public static final int SHOW_AS_ACTION_WITH_TEXT = 4; /** * This item's action vIEw collapses to a normal menu item. * When expanded, the action vIEw temporarily takes over * a larger segment of its container. */ public static final int SHOW_AS_ACTION_ColLAPSE_ACTION_VIEW = 8; ...}
This链接到MenuItem类的源代码
总结以上是内存溢出为你收集整理的Android常数值至常数名称(app:showAsAction =“ 2”)全部内容,希望文章能够帮你解决Android常数值至常数名称(app:showAsAction =“ 2”)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)