菜单与操作栏福尔摩斯 [英] Menu with action bar sherlock

查看:134
本文介绍了菜单与操作栏福尔摩斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个例子或教程 如何添加用行动吧福尔摩斯菜单项

I need an example or a tutorial on how to add menu items with action bar sherlock

当我使用简单的菜单 与进口

When I use the simple menu with the imports

import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

当我打电话

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.settings_menu, menu);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) {

        switch (item.getItemId()) {
        case R.id.goToSettings:
            startActivity(new Intent(this, SetPreference.class));
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }

    }

然后我得到了不能覆盖从SherlockActivity错误的最终方法​​。

then I get the Cannot override the final method from SherlockActivity error.

推荐答案

您必须使用菜单 MenuInflater 菜单项 com.actionbarsherlock.view 类包:

You have to use Menu, MenuInflater and MenuItem classes from com.actionbarsherlock.view package:

import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.settings_menu, menu);

    return super.onCreateOptionsMenu(menu);
}

顺便说一句, ActionBarSherlock 含有大量的样本。

这篇关于菜单与操作栏福尔摩斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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