简体   繁体   English

ActionBar菜单图标仅显示在溢出菜单上

[英]ActionBar Menu icons only shows on overflow menu

I am currently having an issue showing the option menu items on the actionbar. 我目前在操作栏上显示选项菜单项时遇到问题。 For some reason, the items only show on the overflow menu and this is true for post ICS devices as well. 由于某些原因,这些项目仅显示在溢出菜单上,这对于后ICS设备也是如此。 I am using the v7-appcompat library to support sdks from version 8 onwards. 我正在使用v7-appcompat库来支持从版本8开始的SDK。

In the main activity I have: 在主要活动中,我有:

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

My menu items are defined as follow: 我的菜单项定义如下:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      **xmlns:app="http://schemas.android.com/apk/res-auto"** >

  <item
    android:id="@+id/menu_refresh"
    android:icon="@drawable/ic_action_refresh"
    **app:showAsAction="always"**
    android:title="@string/menuTitle_refresh"/>
<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    **app:showAsAction="ifRoom"**
    android:title="@string/action_settings"/>

I also have a spinner in the actionbar with the following xml layout: 我在动作栏中也有一个带有以下xml布局的微调框:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:minHeight="50dp"
       android:minWidth="140dp"
       android:layout_gravity="center_vertical"
       style="@style/ActionBarNavListTitle" />

I can't seem to get my head around it. 我似乎无法解决这个问题。

太好了,我发现此问题与我现在已解决的ActionBar样式定义不匹配有关:

<style name="ActionBarStyle"   parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM