简体   繁体   English

如何在android中将onclick添加到cardview以在webview中打开链接

[英]How to add onclick to cardview in android to open link in webview

我有 gridview 中的卡片列表都是静态的,我想在每张卡片上添加 onclick 并在点击不同卡片的不同链接时在 webview 中打开一个链接。

https://antonioleiva.com/recyclerview-listener/ https://antonioleiva.com/recyclerview-listener/

use this for reference for onclick item of recyclerview.将此作为recyclerview的onclick项的参考。

NOTE笔记

below sentence will be understood, only when you follow the above link下面的句子会被理解,只有当你按照上面的链接

Now after doing all the steps, you will have a method in Activity after implementing the interface.现在完成所有步骤后,您将在实现接口后在 Activity 中拥有一个方法。 pass the position to the method.将位置传递给方法。

In that method, add switch case, based on position you got, call the webview with that particular uri.在该方法中,根据您获得的位置添加 switch case,使用该特定 uri 调用 webview。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM