Featured post
android - Adding menu options to webview code -
i have scoured net solution far unsuccessful. can me. newb , don't know java programming. tutorials on web, have created "webview" app loads local html files. works fine. i'm trying add options menu clicking "menu" button on phone can quit(exit) app. there many tutorials out there when try add code java file, existing code in file start coming errors & goes haywire. hoping can add appropriate code existing code below or correct code if wrong menu options included quit app. thank 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 activity 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 loaded //web.loadurl("http://mapa.org.my"); web.setwebviewclient(new webviewclient() { @override public boolean shouldoverrideurlloading(webview view, string url) { return false; } }); }
}`
there nothing in code has whatsoever options menu. here 2 sample projects demonstrating use of options menus , context menus, one using menu xml files, , one defining menus purely in java.
- Get link
- X
- Other Apps
Comments
Post a Comment