The onClick() of ClickableSpan is not working for URLSpan?

前端 未结 1 1095
萌比男神i
萌比男神i 2021-02-13 04:58

In a TextView, I want to popup a toast whenever a hyperlink is clicked, instead of opening the corresponding url in a browser. I use the following code, but the problem here is

1条回答
  •  有刺的猬
    2021-02-13 05:34

    Actually my senior figured out, we need to remove the original URLSpan before adding our own spans using setSpan()

        // The original URLSpan needs to be removed to block the behavior of browser opening
        strBuilder.removeSpan(span);
    

    Thanks Damian.

    0 讨论(0)
提交回复
热议问题