In strings.xml I have for the keyword
by_continuing_you_agree_terms_and_policy
the string
By continuing, you agree our Terms of Service and <a href="https://www.google.com">Privacy Policy</a>
This is the TextView:
<TextView
android:id="@ id/createAccountTermsText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="8dp"
android:text="@string/by_continuing_you_agree_terms_and_policy"
android:textColor="#A1A1A1" />
but nothing happens when I tap it.
Based on the "solutions" in other questions I added
android:autoLink="web"
android:linksClickable="true"
doesn't work too so I added:
binding.createAccountTermsText.movementMethod = LinkMovementMethod.getInstance()
doesn't work too!
This is not the first idiocy I see with Android SDK. Android seems to be a very horrendous software to develop apps for, period
CodePudding user response:
It works when using
binding.createAccountTermsText.movementMethod = LinkMovementMethod.getInstance()
without
android:autoLink="web"
android:linksClickable="true"
CodePudding user response:
android:autoLink="web"
makes something like http://www.google.com in the text clickable. Not <a href="https://www.google.com">Privacy Policy</a>
If you want use "a href" you need in code
val html=getString(R.string.linked_string)
textview.movementMethod=LinkMovementMethod.getInstance()
textview.text=Html.fromHtml(html, Html.FROM_HTML_MODE_COMPACT)
in string.xml replace < with <
Don't forget turn off android:autoLink="web".
