package firsrdroid.tutorial.mywebview;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;public class UsingMyWebview extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main );
WebViewClient yourWebClient = new WebViewClient()
{
// Override page so it's load on my view only
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
// This line we let me load only pages inside Firstdroid Webpage
if ( url.contains("firstdroid") == true )
// Load new URL Don't override URL Link
return false;
// Return true to override url loading (In this case do nothing).
return true;
}
};
// Get Web view
mWebView = (WebView) findViewById( R.id.MyWebview ); //This is the id you gave
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSupportZoom(true); //Zoom Control on web (You don't need this
//if ROM supports Multi-Touch
mWebView.getSettings().setBuiltInZoomControls(true); //Enable Multitouch if supported by ROM
mWebView.setWebViewClient(yourWebClient);
// Load URL
mWebView.loadUrl("http://www.firstdroid.com/advertisement.htm");
}//End of Method onCreate
}
标签:触摸,mWebView,URL,字串,import,webView,true,WebView,android
From: https://blog.51cto.com/u_16166892/6525366