
我有一个简单的helloworld应用程序.我试图告诉活动用户单击了“ Cnn.com”
WebVIEwClIEnt wc = new WebVIEwClIEnt() { @OverrIDe public boolean shouldOverrIDeUrlLoading(WebVIEw vIEw,String url) { if (url.equals("http://cnn.com/")) { //TELL ACTIVITY CNN WAS CliCKED return true; } else { return false; } } }; mWebVIEw.setWebVIEwClIEnt(wc);我该怎么做.
(我来自C#.NET背景)
最佳答案public class YourActivity extends Activity{ // bla bla bla // the code you already have WebVIEwClIEnt wc = new WebVIEwClIEnt() { @OverrIDe public boolean shouldOverrIDeUrlLoading(WebVIEw vIEw,String url) { if (url.equals("http://cnn.com/")) { YourActivity.this.tellMe(); return true; } else { return false; } } }; // this is the method to 'tell' the activity that someone clicked the link public voID tellMe(){ // in this case I just raise a toast. // but you can do whatever you want here ;) Toast.makeText(YourActivity.this,"eyy!! somebody clicked the cnn link",1).show(); }} 总结 以上是内存溢出为你收集整理的Android WebView从WebViewClient到Activity通信 全部内容,希望文章能够帮你解决Android WebView从WebViewClient到Activity通信 所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)