Sometimes, in android developement, we want to make our textview’s
text clickable, that is, when user click a link in textview’s content,
user would open an activity,here are the code examples:
in res/values/strings.xml, there is a string like this:
Here we want the user can click ‘here’ to open an activity named RegisterActivity
then, in AndroidManifest.xml add an intent filter to RegisterActivity:
the most important part is the second intent-filter, which includes “android.intent.action.VIEW” action and the data settings.
Here ,we set the schema to “RegisterActivity”,then in your strings.xml ,you just set
the link as this:
the ra is the path of the url,
you can pass some parameters to the activity.
in the layout, you have a textview like this:
at last, you change the code of the textview,add init code like this:
The most import line of the upper code is:
the LinkMovementMethod make your text link clickable.
Then , you can test it.
You can find detail android documents about the data intent-filter here: