我在TextView
中建立了一个标准LinkMovementMethod
,用于在用户触摸链接时推送某种类型的网络活动。但是,我想建立一个"你想看到链接"对话而不是直接将用户带到网页。我试过重写触摸方法,但这一切都有点令人费解。一点帮助?
答案 0 :(得分:1)
您可以通过两种方式完成此任务:
LinkMovementMethod
以接受自定义点击监听器在我看来,第二种解决方案在像你这样的基本情况下更好。以下是如何做到这一点:
OnLinkClickedListener clickListener = new OnLinkClickedListener() {
@Override
public boolean onLinkClicked(String linkText) {
// here you can handle your click, eg show the dialog
// `linkText` is the text being clicked (the link)
// return true if handled, false otherwise
}
}
yourTextView.setMovementMethod(new InternalLinkMovementMethod(clickListener));