简体   繁体   English

android-溢出动作栏菜单

[英]overflow actionbar menu android

i imported the library from here, inorder to use it as actionbar: 我从这里导入库,以便将其用作操作栏:

https://github.com/johannilsson/android-actionbar https://github.com/johannilsson/android-actionbar

however i didnt find how can i implement a overflow menu item? 但是我没有找到如何实现溢出菜单项的方法?

for example, in actionbarsherlock this code to implement the overflow menu item is: 例如,在actionbarsherlock中,用于实现溢出菜单项的代码是:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:id="@+id/root_menu"
    android:icon="@drawable/ic_menu_moreoverflow_normal_holo_light"
    android:showAsAction="always"
    android:title="More">
    <menu>
        <item
            android:id="@+id/menu_settings"
            android:icon="@drawable/ic_menu_settings_holo_light"
            android:showAsAction="never"
            android:title="Settings" />
        <item
            android:id="@+id/menu_about"
            android:icon="@drawable/ic_menu_info_details"
            android:showAsAction="never"
            android:title="About"/>
   </menu>
</item>
</menu> 

can someone help me with it? 有人可以帮我吗? maybe the developer of this code can help me? 也许这段代码的开发人员可以帮助我?

thanks alot 非常感谢

same way you can implement system actionbar menu. 与实现系统操作栏菜单的方式相同。 no need to use any lib or other just use this code for your menu and it will work for you and for generating your menu use oncreateoptionmenu/onprepareoptionmenu for example using with this code 无需使用任何lib或其他文件,只需在菜单上使用此代码即可,它将为您工作并生成菜单,请使用oncreateoptionmenu / onprepareoptionmenu例如与此代码一起使用

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:id="@+id/root_menu"
    android:icon="@drawable/ic_menu_moreoverflow_normal_holo_light"
    android:showAsAction="always"
    android:title="More">
    <menu>
        <item
            android:id="@+id/menu_settings"
            android:icon="@drawable/ic_menu_settings_holo_light"
            android:showAsAction="never"
            android:title="Settings" />
        <item
            android:id="@+id/menu_about"
            android:icon="@drawable/ic_menu_info_details"
            android:showAsAction="never"
            android:title="About"/>
   </menu>
</item>
</menu> 

now inflate this menu in your activity/fragementactivity using oncreateoptionmenu/onprepareoptionmenu 现在,使用oncreateoptionmenu / onprepareoptionmenu在活动/碎片活动中扩展此菜单

here is the using of action menu 这是动作菜单的使用

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()){
    case R.id.menu_settings:
        Toast.makeText(context,"Setting menu selected",Toast.SHORT_LENGTH).show();
        break;      
    case R.id.menu_about:
        Toast.makeText(context,"About menu selected",Toast.SHORT_LENGTH).show();
        break;
    }
    return super.onOptionsItemSelected(item);
}

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

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