[英]Change link color when using LinkMovementMethod and Html.fromHtml
[英]Intercept link LinkMovementMethod with a Yes/No dialog
我在TextView
建立了一個標准LinkMovementMethod
,以在用戶觸摸鏈接時推送某種形式的Web Activity。 但是,我想建立一個“您是否想看到鏈接”對話框,而不是直接將用戶帶到網頁。 我嘗試覆蓋觸摸方法,但是這一切都有些令人費解。 一點幫助?
您可以通過兩種方式完成此任務:
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));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.