Control onclicklistener in autolink enabled textview

前端 未结 9 2646
一向
一向 2020-12-08 19:13

I am using a TextView for which I have set autolink=\"web\" property in XML file. I have also implemented the onClickListener for this TextView. Th

9条回答
  •  半阙折子戏
    2020-12-08 19:31

    Use textView.getSelectionStart() and textView.getSelectionEnd().If u click any text other than link textView.getSelectionStart() and textView.getSelectionEnd() will be -1 .So by using a if condition in onClickListner you can block the onClick action when link is clicked .

    //inside onClickListner
    
    if(textView.getSelectionStart()==-1&&textView.getSlectionEnd==-1){
    
        //onClick action
    }
    

提交回复
热议问题