Format TextView to look like link

前端 未结 7 1558
醉话见心
醉话见心 2021-01-04 02:21

I\'ve been using the android:autoLink just fine for formatting links and such, but I need to use android:onClick so I can\'t use that in this case.

7条回答
  •  囚心锁ツ
    2021-01-04 02:59

    Have a better answer.This is what i did.

         final SpannableString ss = new SpannableString("Click here to verify Benificiary");
            ClickableSpan clickableSpan = new ClickableSpan() {
                @Override
                public void onClick(View textView) {
    
                }
                @Override
                public void updateDrawState(TextPaint ds) {
                    super.updateDrawState(ds);
                    ds.setUnderlineText(false);
                }
            };
            ss.setSpan(clickableSpan,0,ss.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
            textView.setHighlightColor(Color.BLUE);
    

    You go anywhere you like when user clicks on the link through onclick method of ClickableSpan

提交回复
热议问题