6
我在这里遇到了一个很大的错误。 我试图用supportInvalidateOptionsMenu()更改操作栏菜单;但是当函数执行时,应用程序关闭,没有错误。Sherlock Actionbar invalidateOptionsMenu()
奇怪的是,一切都正常工作在我的Galaxy Nexus(4.2.2),但不会在我的朋友的手机(安卓4.0.3),也不在我的仿真器与Android 2.1
这里是我的工作代码:
protected void onCreate(Bundle savedInstanceState) {
...
actionbar = getSupportActionBar();
...
myWebView = (WebView) findViewById(R.id.webview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.addJavascriptInterface(new WebAppInterface(this), "Android");
myWebView.loadUrl(getString(R.string.site_load));
...
}
public class WebAppInterface {
SherlockActivity mActivity;
WebAppInterface(SherlockActivity c) {mActivity = c;}
public void setrefreshon() {showRefresh = true; mActivity.supportInvalidateOptionsMenu();}
}
有人可以帮助我吗? :/
谢谢!解决了 – 2013-02-19 19:12:41