Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void singleTextView(TextView textView, final String userName, String status, final String songName) {
- SpannableStringBuilder spanText = new SpannableStringBuilder();
- spanText.append(userName);
- spanText.setSpan(new ClickableSpan() {
- @Override
- public void onClick(View widget) {
- // On Click Action
- }
- @Override
- public void updateDrawState(TextPaint textPaint) {
- textPaint.setColor(textPaint.linkColor); // you can use custom color
- textPaint.setUnderlineText(false); // this remove the underline
- }
- }, spanText.length() - userName.length(), spanText.length(), 0);
- spanText.append(status);
- spanText.append(songName);
- spanText.setSpan(new ClickableSpan() {
- @Override
- public void onClick(View widget) {
- // On Click Action
- }
- @Override
- public void updateDrawState(TextPaint textPaint) {
- textPaint.setColor(textPaint.linkColor); // you can use custom color
- textPaint.setUnderlineText(false); // this remove the underline
- }
- },spanText.length() - songName.length(), spanText.length(), 0);
- textView.setMovementMethod(LinkMovementMethod.getInstance());
- textView.setText(spanText, TextView.BufferType.SPANNABLE);
- }
Add Comment
Please, Sign In to add comment