大佬教程收集整理的这篇文章主要介绍了android – Web视图不加载重定向网址,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
webview的代码是:
webView = (WebView) findViewById(R.id.simpleWebView); WebSetTings webSetTings = webView.getSetTings(); webSetTings.setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient()); if(geTintent().getStringExtra("url")!=null){ loadLink(geTintent().getStringExtra("url")); }else{ Toast.makeText(WebViewActivity.this,"Please try again later!",Toast.LENGTH_SHORT).show(); finish(); }
public class Main extends Activity { private WebView webview; private static final String TAG = "Main"; private ProgressDialog progressBar; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceStatE) { super.onCreate(savedInstanceStatE); requestWindowFeature(Window.FEATURE_NO_titlE); setContentView(R.layout.main); this.webview = (WebView)findViewById(R.id.webview); WebSetTings setTings = webview.getSetTings(); setTings.setJavaScriptEnabled(true); webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); final AlertDialog alertDialog = new AlertDialog.builder(this).create(); progressBar = ProgressDialog.show(Main.this,"WebView Example","Loading..."); webview.setWebViewClient(new WebViewClient() { public Boolean shouldOverrideUrlLoading(WebView view,String url) { Log.i(tag,"Processing webview url click..."); view.loadUrl(url); return true; } public void onPageFinished(WebView view,"Finished loading URL: " +url); if (progressBar.isShowing()) { progressBar.dismiss(); } } public void onReceivedError(WebView view,int errorCode,String description,String failingUrl) { Log.e(tag,"Error: " + description); Toast.makeText(activity,"Oh no! " + description,Toast.LENGTH_SHORT).show(); alertDialog.settitle("Error"); alertDialog.setmessage(description); alertDialog.setButton("OK",new DialogInterface.onClickListener() { public void onClick(DialogInterface dialog,int which) { return; } }); alertDialog.show(); } }); webview.loadUrl("http://www.google.com"); } }
你的main.xml布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://scheR_174_11845@as.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <WebView android:id="@String/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> </LinearLayout>
以上是大佬教程为你收集整理的android – Web视图不加载重定向网址全部内容,希望文章能够帮你解决android – Web视图不加载重定向网址所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。