菜单与操作栏福尔摩斯福尔摩斯、菜单、操作

由网友(霸道菇凉最给力)分享简介:我需要一个例子或教程如何添加用行动吧福尔摩斯菜单项I need an example or a tutorialon how to add menu items with action bar sherlock当我使用简单的菜单与进口When I use the simple menu with the...

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

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 含有大量的样本。

阅读全文

相关推荐

最新文章