我如何将项目添加到我的动作条? [英] How can I add items to my actionbar?

查看:195
本文介绍了我如何将项目添加到我的动作条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经试过周围寻找,但我只限于互联网的使用,直到16日,所以我对我怎么能实现按钮我的行动吧东张西望一个很小的数额。

I've tried searching around but I am only limited to a very minimal amount of internet usage till 16th so I was looking around on how I could implement buttons to my action bar.

右键所以当你进入播放列表节上我的应用程序,对布局的关于按钮。但我还想给该按钮移动到我的行动吧,我怎么能做到这一点?

Right so when you enter the playlist section on my app, there is an about button on the layout. But id like to move that button to my action bar, how can I achieve this?

推荐答案

这是如何添加帮助图标到你的动作栏中的例子

This is an example how you can add HELP icon to your action bar

像下面的菜单文件夹内创建一个XML菜单

Create a menu XML inside your menu folder like the following

<item
    android:id="@+id/help_menu_item"
    android:icon="@android:drawable/ic_menu_help"
    android:title="Help"
    android:showAsAction="ifRoom" /> 

和您的活动做这样的事情。

And in your activity do something like that

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.help_menu, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
        case R.id.help_menu_item:
            //do your menu press here       
            return true;

        default:
            return super.onOptionsItemSelected(item);
    }
}

这篇关于我如何将项目添加到我的动作条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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