0

The texts looks clickable but the onCLickListener is not detecting any clicks. Not sure what the problem is?

    smallPrint = findViewById(R.id.smallPrint);

    SpannableString fullText = new SpannableString(getResources().getString(R.string.welcome_smallPrint));
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View textView) {
            startActivity(new Intent(WelcomeScreen.this, TermsAndConditions.class));
        }
    };
    fullText.setSpan(clickableSpan, 35, 53, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    smallPrint.setText(fullText); 
Maja Okholm
  • 3,147
  • 2
  • 11
  • 17
  • 1
    You have to set a `LinkMovementMethod` on the `TextView`, IIRC. That is, e.g., `smallPrint.setMovementMethod(LinkMovementMethod.getInstance())`. – Mike M. Aug 15 '19 at 13:47
  • Yeah, it actually mentions that in [the docs for `ClickableSpan`](https://developer.android.com/reference/android/text/style/ClickableSpan) (though I'm not sure that it always did). – Mike M. Aug 15 '19 at 14:03

0 Answers0