gpt4 book ai didi

即使使用应用程序 :showAsAction always,Android 菜单项也会显示在溢出区域

转载 作者:行者123 更新时间:2023-11-29 19:09:00 26 4
gpt4 key购买 nike

<分区>

我正在使用 MainActivity 来扩展 Activity 类。项目使用的 API 最低为 11。当我膨胀菜单项时,它总是显示在溢出中。

public class MainActivity extends Activity {
....
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the Menu Items
getMenuInflater().inflate(R.menu.menu_main,menu);
return true;
}

menu_main.xml

<?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"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item android:id="@+id/attach"
android:title="Attachment"
android:orderInCategory="1"
app:showAsAction="always"/>

</menu>

样式.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

26 4 0