I have the text \"Android is a Software stack\". In this text i want to set the \"stack\" text is clickable. in the sense if you click on t
It really helpful for the clickable part for some portion of the text.
The dot is a special character in the regular expression. If you want to spanable the dot need to escape dot as \\. instead of just passing "." to the spanable text method. Alternatively, you can also use the regular expression [.] to spanable the String by a dot in Java.
To add a linked text in a text view, you can use the "footer_text" string resource example below and also edit your onCreate method for your activity, you can use the example below
string.xml
<?xml version="1.0" charset="utf-8"?>
<resources>
<string name="app_name">Name of My Application</string>
<string name="footer_text">
<a href="https://www.google.com/tos">Terms of Service</a>
<a href="https://www.google.com/contact">Contact</a>
<a href="https://www.google.com/privacy">Privacy Policy</a>
</string>
</resources>
MainActivity.java
...
@Override
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
setContentView(R.layout.activity_main);
TextView textView = findViewById(R.id.textViewLink);
textView.setMovementMethod(LinkMovermentMethod.getInstance());
}
....