Reputation: 9
I have scoured the net for this solution but am thus far unsuccessful. Hopefully someone can help me. I am new and don't know java programming. From tutorials over the web, i have created a "webview" app that loads local html files. This works fine. What i'm trying to do is add the options menu by clicking the "menu" button on the phone so i can quit(exit) the app. There are many tutorials out there for this but when i try to add the code my java file, my existing code in the file start coming up with errors & then everything goes haywire. I am hoping someone can add the appropriate code to my existing code below or correct my code if it is wrong with the menu options included to quit the app. Thank you in advance.
Su
package com.xrefguide;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class XRefGuide extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView web = (WebView) findViewById(R.id.webView);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("file:///android_asset/index.html");
web.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
web.getSettings().setPluginsEnabled(true);
web.getSettings().setSupportMultipleWindows(false);
web.getSettings().setSupportZoom(true);
web.setVerticalScrollBarEnabled(false);
web.setHorizontalScrollBarEnabled(false);
web.getSettings().setBuiltInZoomControls(true);
web.getSettings().setLoadWithOverviewMode(true);
web.getSettings().setUseWideViewPort(true);
//Our application's main page will be loaded
//web.loadUrl("http://mapa.org.my");
web.setWebViewClient(new WebViewClient() {
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
}
}
Upvotes: 0
Views: 4657
Reputation: 1006829
There is nothing in your code that has anything whatsoever to do with an options menu. Here are two sample projects demonstrating the use of options menus and context menus, one using menu XML files, and one defining the menus purely in Java.
Upvotes: 1