Android: ClickableSpan in clickable TextView

后端 未结 7 1762
借酒劲吻你
借酒劲吻你 2020-11-27 02:53

I have a textview that can contain clickable links. When one of this links is clicked, I want to start an activity. This works fine, but it should also be possible to click

7条回答
  •  囚心锁ツ
    2020-11-27 03:16

    This is a quite easy solution.. This worked for me

    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ClassroomLog.log(TAG, "Textview Click listener ");
            if (textView.getSelectionStart() == -1 && textView.getSelectionEnd() == -1) {
                // do your code here this will only call if its not a hyperlink
            }
        }
    });
    

提交回复
热议问题