Just only orange part can click,so my code can't just use a Textview
How I design the UI, I know use Html code can make color different,but I need click part just only orange
Thanks In Advance
Just only orange part can click,so my code can't just use a Textview
How I design the UI, I know use Html code can make color different,but I need click part just only orange
Thanks In Advance
For that, you have to use a class named SpannableString. look here how to use it in kotlin - https://medium.com/@programmerr47/working-with-spans-in-android-ca4ab1327bc4
I hope this is what you searching for
TextView myTextView = new TextView(this);
String myString = "Some text [clickable]";
int i1 = myString.indexOf("[");
int i2 = myString.indexOf("]");
myTextView.setMovementMethod(LinkMovementMethod.getInstance());
myTextView.setText(myString, BufferType.SPANNABLE);
Spannable mySpannable = (Spannable)myTextView.getText();
ClickableSpan myClickableSpan = new ClickableSpan() {
@Override
public void onClick(View widget) { /* do something */ }
};
mySpannable.setSpan(myClickableSpan, i1, i2 + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
If you need more Reference please follow the link