gpt4 book ai didi

android - Samsung Galaxy S3 中的选项菜单

转载 作者:太空宇宙 更新时间:2023-11-03 12:18:24 25 4
gpt4 key购买 nike

是否可以强制 Samsung Galaxy S3 将选项菜单固定在屏幕右上角,就像在其他流行手机中一样?在 Samsung Galaxy S3 中,选项菜单仅在菜单按钮下可用。我想在所有类型的设备的固定位置放置应用程序的内置帮助。

我不确定其他类型的手机/平板电脑是否出现类似问题。

最佳答案

在包含选项菜单的 Activity 中使用此代码块。

try {
ViewConfiguration config = ViewConfiguration.get(BaseActivity.this);
Field menuKeyField = ViewConfiguration.class
.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception e) {
e.printStackTrace();
}

通过此 block ,使用可以从操作栏的右上角访问选项菜单。
即使在三星 Galaxy S3 上,当您单击菜单按钮时,选项菜单也会从操作栏的右上角打开。尝试使用以下 menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
android:orderInCategory="2"
android:title="Home"/>
<item
android:id="@+id/logs"
android:orderInCategory="3"
android:title="Logs"/>
<item
android:id="@+id/support"
android:orderInCategory="4"
android:title="Support"/>
<item
android:id="@+id/logout"
android:orderInCategory="5"
android:title="Logout"/>

</menu>

关于android - Samsung Galaxy S3 中的选项菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25404974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com