I used Android.text.style.ClickableSpan
to make a part (Black
) of a string (Blue | Black
) clickable:
SpannableString spannableString = new SpannableString("Blue | Black ");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
//...
}
};
ss.setSpan(clickableSpan, 7, 11, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView textView = (TextView) findViewById(R.id.secondActivity_textView4);
textView.setText(spannableString);
textView.setMovementMethod(LinkMovementMethod.getInstance());
So Black
part of the string is clickable. What I want is that when the user clicks Black
, it should make Black
Not-clickable, and Blue
(another part of the same string) clickable.
So to make Blue
clickable, we can call setSpan()
on the same spannableString
another time. But how can I make Black
not-clickable?