简体   繁体   English

如何使用actionbarsherlock将菜单项添加到操作栏?

[英]How can I add a menu item to the action bar with actionbarsherlock?

I have started my android application with the standard holo theme. 我已经使用标准的holo主题启动了我的android应用程序。 Then I added the tabs functionality and now I would like to add a small settings button in the action bar. 然后,我添加了选项卡功能,现在我想在操作栏中添加一个小的设置按钮。

How can I do that. 我怎样才能做到这一点。 I already set this method: 我已经设置了此方法:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
   com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
   inflater.inflate(R.menu.activity_main, (com.actionbarsherlock.view.Menu) menu);
   return super.onCreateOptionsMenu(menu);
}

尝试这个:

menu.add("some title").setIcon(R.drawable.[your image]).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

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

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