我如何将项目添加到我的动作条?

我如何将项目添加到我的动作条?

问题描述:

我已经试过周围寻找,但我只限于互联网的使用,直到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);
    }
}