Android studio use same span multiple times

Viewed 53

I'm working on the android studio project which requires using same span multiple times in the text. I know the setspan method would clear the previous same span. I'm just wondering if there are any approach to solve these kind of problems without using so many different spans.

ClickableSpan clk = new ClickableSpan() {
    @Override
    public void onClick(@NonNull View view) {
        Toast.makeText(MainActivity.this, "hi", Toast.LENGTH_SHORT).show();
    }
};
ss.setSpan(clk, 20, 23, 0);
ss.setSpan(clk, 17, 19, 0);
text.setText(ss);
0 Answers
Related