I have a textview as like the following:
txtByRegistering.setText(\"By Registering you agree to terms and condition and privacy policy\");
Use this one it works for me two click in single TextView
Step1-: Your text will be in SpannableString
SpannableString ss = new SpannableString("By Registering you agree to terms and condition and privacy policy");
Step2:-add click in ClickableSpan like this
ClickableSpan Registering = new ClickableSpan() {
@Override
public void onClick(View textView) {
Intent intent=new Intent(this,WebView_Activity.class);
startActivity(intent);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(true);
}
};
ClickableSpan terms = new ClickableSpan() {
@Override
public void onClick(View textView) {
Intent intent=new Intent(this,WebView_Activity.class);
startActivity(intent);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(true);
}
};
Final step add your click on SpannableString with character starting and ending index like Registering word in start at 3rd position and end at 11 so add click for Registering word
ss.setSpan(Registering , 3, 11, 0);
same for term after this add your SpannableString on your TextView
textview.setMovementMethod(LinkMovementMethod.getInstance());
textview.setText(ss, TextView.BufferType.SPANNABLE);
textview.setSelected(true);