gpt4 book ai didi

Android 操作栏溢出图标不可见

转载 作者:行者123 更新时间:2023-11-30 01:41:52 25 4
gpt4 key购买 nike

我需要在没有任何子菜单项的情况下在我的应用程序中显示操作栏溢出图标,并且我需要在单击操作栏溢出图标时显示一个抽屉。

使用下面的代码不显示溢出图标,在向菜单添加项目时显示图标。

是否可以在没有任何内容的情况下显示溢出图标?我还需要获取溢出图标的点击事件,这可能吗?

<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="com.ibeacon.vapplicaspecials.MainActivity" >

<item
android:id="@+id/overflow"
android:orderInCategory="100"
android:showAsAction="always"
android:title="">

</item>

</menu>

在主要 Activity 中

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);

return super.onCreateOptionsMenu(menu);
}

最佳答案

如果您的 Activity 正在扩展 AppCompat,我建议您使用 android.support.v7.widget.Toolbar。它更易于使用,而且您不必拥有操作栏的所有额外方法。可以放图标、自定义动画等等……在考虑实现material Design动画和功能时也是非常不错的选择。

Android: How to/Tutorial for changing ActionBar to ActionBarCompat (Toolbar)?

关于Android 操作栏溢出图标不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34390598/

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