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();}@H_502_6@解决方法 主类
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://schemas.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>@H_502_6@ @H_502_6@ 总结
以上是内存溢出为你收集整理的android – Web视图不加载重定向网址全部内容,希望文章能够帮你解决android – Web视图不加载重定向网址所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)