Back to project page advanced-textview.
The source code is released under:
Apache License
If you think the Android project advanced-textview listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.sqisland.android.advanced_textview; /* w ww. j a va 2 s.com*/ import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.SpannableString; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.view.View; import android.widget.TextView; public class ClickableSpanActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_clickable_span); TextView textView = (TextView) findViewById(R.id.text); String text = textView.getText().toString(); String goToSettings = getString(R.string.go_to_settings); int start = text.indexOf(goToSettings); int end = start + goToSettings.length(); SpannableString spannableString = new SpannableString(text); spannableString.setSpan(new GoToSettingsSpan(), start, end, 0); textView.setText(spannableString); textView.setMovementMethod(new LinkMovementMethod()); } private static class GoToSettingsSpan extends ClickableSpan { @Override public void onClick(View view) { view.getContext().startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS)); } } }