Sergei Mikhailovskii
Sergei Mikhailovskii

Reputation: 2465

Cannot remove clickListener from TextView and set it to spannable text

I have the following situation: there is the textview on my screen. This textview has onClickListener. Than I need to set Spannable text to this textView. The part of the spannable text has it's own click listener. For this purpose, I clear textview listener, but in this situation, TextView is not clickable at all:

public void setExpandableClickListenerForPaymentsMethod(SpannableStringBuilder spannableStringBuilder) {
    loanDetailTv.setOnClickListener(null);

    ClickableSpan linkSpan = new ClickableSpan() {
        @Override
        public void onClick(@NonNull View widget) {
            getController().onRestructingClick();
        }
    };
    spannableStringBuilder.setSpan(linkSpan, 45, 129, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    loanDetailTv.setText(spannableStringBuilder);
}

What's the reason and how can I solve it?

Upvotes: 0

Views: 46

Answers (1)

julianpjp
julianpjp

Reputation: 112

try to make the textview not clickable like this:

textview.clickable = false; 

Upvotes: 1

Related Questions