Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android Action Bar三点不显示大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
请帮忙,
做了一个自定义菜单(添加支持库)(name-> main_activity_actions.xml)
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://scheR_302_11845@as.android.com/apk/res/android"
xmlns:yourapp="http://scheR_302_11845@as.android.com/apk/res-auto"  >

<item
    android:id="@id/search"
    android:icon="@drawable/search"
    android@R_922_6964@="@String/search"
    yourapp:showAsAction="ifRoom" />
<item
    android:id="@id/view_all"
    android@R_922_6964@="@String/view_all"
    yourapp:showAsAction="never"/>
<item
    android:id="@+id/action_setTings"
    yourapp:showAsAction="never"
    android@R_922_6964@="@String/action_setTings"/>

现在我该怎么做,将action_setTings放入三个点(动作栏),而不是硬件菜单按钮(没有任何黑客).

主要活动

@Override
    public Boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if @R_801_8913@ present.
    getMenuInflater().inflate(R.menu.main_activity_actions,menu);
    return true;
}

好吧,我找到了黑客,但如果有任何其他方式然后让我知道,

将此代码放在onCreate中

try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPeRMANentMenuKey");
        if(menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config,falsE);
        }
    } catch (Exception eX) {
        // Ignore
    }

为此,您需要导入

import java.lang.reflect.Field;
import android.view.ViewConfiguration;

解决方法

没有任何黑客,你不能在所有设备上这样做.那些具有硬件菜单按钮的设备(我不知道是否绝对全部)将使用它而不是溢出按钮(…).

哪一种,是一件好事.这些设备的用户用于按菜单按钮进入菜单.所以对他们来说,缺少溢出按钮是正常的行为.

对于那些使用溢出按钮的设备,Android将根据您在showAsAction标签中的@L_618_19@来决定自己的内容.这取决于屏幕尺寸,方向等等. This page有一张表,显示有多少个图标显示(其余的显示到溢出菜单).

大佬总结

以上是大佬教程为你收集整理的Android Action Bar三点不显示全部内容,希望文章能够帮你解决Android Action Bar三点不显示所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。