
我有一个webvIEw,我从web服务调用该wv中的数据,在webvIEw中的整个描述中,最后有一个链接.所以,我的问题是,我想打开一个新的活动点击该链接既没有onvIEw的webvIEw也没有onvIEw的webvIEw
解决方法:
您需要提供shouldOverrideUrlLoading的实现.您必须为您的webvIEw设置WebVIEwClIEnt,并且在此方法内部,您需要具有一些识别该链接的逻辑,然后打开新的Activity.就像是:
protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); WebVIEw wv = (WebVIEw) findVIEwByID(R.ID.myWebVIEw); wv.setWebVIEwClIEnt(new WebVIEwClIEnt(){ @OverrIDe public boolean shouldOverrIDeUrlLoading(WebVIEw vIEw, String url) { if(isURLMatching(url)) { openNextActivity(); return true; } return super.shouldOverrIDeUrlLoading(vIEw, url); } }); } protected boolean isURLMatching(String url) { // some logic to match the URL would be safe to have here return true; } protected voID openNextActivity() { Intent intent = new Intent(this, MyNextActivity.class); startActivity(intent); } 总结 以上是内存溢出为你收集整理的android – Web视图onclick事件,用于该webview中的特定链接全部内容,希望文章能够帮你解决android – Web视图onclick事件,用于该webview中的特定链接所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)