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