Android的动作条compat的溢出菜单中没有显示SDK 10 [英] Android ActionBar compat overflow menu not showing on sdk 10

查看:159
本文介绍了Android的动作条compat的溢出菜单中没有显示SDK 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,感谢您对你在阅读这个问题的时候。

Hello and thank you for the time you take in reading this question.

我想开发一个Android应用程序将使用的动作条compat的图书馆。我已经使用COMPAT库时遵循(据我看到它)的所有建议。我的清单看起来是这样的(仅与$ C $显示C):

I am trying to develop an android app which will use the ActionBar compat library. I have followed (as far as I see it) all the recommendations when using the compat library. My Manifest looks like this(only relevant code shown):

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application            
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light" >

    </application>

</manifest>

正如你所看到的,我针对SDK 8+。我已经使用了Theme.AppCompat主题,推荐。

As you can see I am targeting sdk 8+. I have used the Theme.AppCompat theme as recommended.

我的菜单文件看起来是这样的:

My menu file looks like this:

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

    <item
        android:id="@+id/action_map"
        android:icon="@drawable/ic_action_map"
        android:title="@string/action_map"
        cds:showAsAction="ifRoom"/>
    <item
        android:id="@+id/action_search"
        android:icon="@drawable/ic_action_search"
        android:title="@string/action_search"
        cds:showAsAction="ifRoom"/>
    <item
        android:id="@+id/action_mail"
        android:icon="@drawable/ic_action_mail"
        android:title="@string/action_mail"
        cds:showAsAction="ifRoom"/>

</menu>

我用我自己的命名空间showAsAction属性。

I am using my own namespace for the showAsAction attribute.

我的活动来延长ActionBarActivity类。

My activity extends the ActionBarActivity class.

问题是这样的:在SDK 10(机器人2.3.3),无论是在设备和仿真,溢出菜单(在右侧的操作杆的三个点)未示出。只有第2的菜单项显示在操作栏。如果我preSS的菜单按钮在设备上,然后在第三项示出了从屏幕(未从右上角作为与较新的Andr​​oid版本的设备)的左下角。同样的code行之有效对模拟器Android SDK中17(溢出菜单显示与适当的行动)。

The problem is this: On sdk 10 (android 2.3.3), both on device and emulator, the overflow menu (the three dots on the right side of the action bar) are not shown. Only the first 2 of the menu items are shown on the action bar. If i press the "Menu" button on the device then the third item is shown from the bottom left corner of the screen (not from the upper right corner as on the devices with more recent android versions). The same code works well on android sdk 17 on emulator (the overflow menu is shown with the proper actions).

我已经在网上搜索一个解决方案,但我无法找到一个与此特定问题。我早就放弃了问题,如果我不会在Android 2.3.3设备具有相同的操作栏并显示溢出菜单图标,妥善像任何最新的Andr​​oid设备上工作,安装的应用程序。这个应用程序的一个例子是todoist应用程序( https://en.todoist.com/android )或handcent应用程序(<一个href="https://play.google.com/store/apps/details?id=com.handcent.nextsms&hl=en">https://play.google.com/store/apps/details?id=com.handcent.nextsms&hl=en)这既表现以及在此设备上。

I have searched the web for a solution but I could not find one with this specific problem. I would have abandoned the issue if I wouldn't have installed apps on the android 2.3.3 device that have the same action bar and which show the overflow menu icon and work properly like on any recent android device. One example of this app is the todoist app (https://en.todoist.com/android) or the handcent app(https://play.google.com/store/apps/details?id=com.handcent.nextsms&hl=en) which both behave well on this device.

有什么我失踪或者是有一个替代的解决方案使用的推荐方法的动作条COMPAT?

Is there anything I am missing or is there an alternative solution to the recommended way of using the actionbar compat?

感谢您的时间。

推荐答案

@Andrei谷歌已禁用appcompat菜单溢出按钮pre honycomb。 如果你真的想将它添加到了Android的GitHub的资源库和下载 platform_frameworks_support。它包含SORCE的appcompat在platform_framework_support_master / V7 / appcompat。

@Andrei Google have disabled the menu overflow button in appcompat on pre honycomb. If You really want to add it go to the android's github repository and download platform_frameworks_support. It contains sorce for appcompat in platform_framework_support_master/v7/appcompat.

创建内部appcompat一个libs文件夹,并把最新的Andr​​oid支持,v4.jar。 现在打开文件V7 / appcompat / src目录/ 安卓/支持/ V7 /内部/视图/ ActionBarPolicy.java 。 你会看到,showoverflowbutton返回false为pre honycomb.Just回是真的,并添加这个编辑appcompat作为库项目 你不需要任何自定义的溢出按钮 这个工作和我在一起。 对不起,我的英语水平

Create a libs folder inside appcompat and put latest android-support-v4.jar. Now open file v7/appcompat/src/android/support/v7/internal/view/ActionBarPolicy.java. You will see that showoverflowbutton is returned false for pre honycomb.Just return it true and add this edited appcompat as library to your project and you will not need any custom overflow button This worked with me . Sorry for my English

编辑:从实际code 安卓/支持/ V7 /内部/视图/ ActionBarPolicy.java

actual code from android/support/v7/internal/view/ActionBarPolicy.java

public boolean showsOverflowMenuButton() {
    // Only show overflow on HC+ devices
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
}

这篇关于Android的动作条compat的溢出菜单中没有显示SDK 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆