I have a TextView in a Layout. It\'s so simple. I put a OnClickListener in the layout and some part of the TextView is set to be ClickableSpan. I want the ClickableSpan to do s
The easiest and fastest way to implement ClickableSpan is:
new SmartClickableSpan
.Builder(this)
.regularText("I agree to all ")
.clickableText(new ClickableOptions().setText("Terms of Use").setOnClick(new
ClickableSpan() {
@Override
public void onClick(@NonNull View view) {
// Your Code..
}
}))
.into(myTextView);
Adding regular Clickable Spans in Android requires calculating sizes for each clickable text, and when it comes to adding a lot of clickable and regular words or sentences in a TextView is becomes a mess.. By using SmartClickableSpan, you'll be able to add whatever amount of clickable words or sentences without any worries of calculating length of each text on every update on it.