Last active
November 11, 2018 05:07
-
-
Save girish3/23b14fa9996f7c128412a52600029d71 to your computer and use it in GitHub Desktop.
[Spannable String] #android_snippet #android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/10696986/how-to-set-the-part-of-the-text-view-is-clickable | |
SpannableString ss = new SpannableString("Android is a Software stack"); | |
ClickableSpan clickableSpan = new ClickableSpan() { | |
@Override | |
public void onClick(View textView) { | |
startActivity(new Intent(MyActivity.this, NextActivity.class)); | |
} | |
}; | |
// 0 is the start index and 7 is the end index | |
ss.setSpan(clickableSpan, 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | |
TextView textView = (TextView) findViewById(R.id.hello); | |
textView.setText(ss); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment