daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class BaldrActivity extends AppCompatActivity {
  2. @Override
  3. protected void onCreate(@Nullable Bundle savedInstanceState) {
  4.     super.onCreate(savedInstanceState);
  5.     setContentView(R.layout.a_dei_baldr);
  6.  
  7.     String myString = "Click Here!";
  8.  
  9.     SpannableString ss = new SpannableString(myString);
  10.  
  11.     ClickableSpan clickableSpan1 = new ClickableSpan() {
  12.         @Override
  13.         public void onClick(View widget) {
  14.             Toast.makeText(BaldrActivity.this, "hello world", Toast.LENGTH_SHORT).show();
  15.         }
  16.  
  17.         @Override
  18.         public void updateDrawState(TextPaint ds) {
  19.             super.updateDrawState(ds);
  20.             ds.setColor(Color.BLUE);
  21.             ds.setUnderlineText(false);
  22.         }
  23.     };
  24.  
  25.     ss.setSpan(clickableSpan1, 6, 11, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  26.  
  27.     TextView tv = findViewById(R.id.tv_baldr1);
  28.     tv.setText(myString);
  29.     tv.setMovementMethod(LinkMovementMethod.getInstance());
  30. }
  31.    
  32. tv.setText(myString);
  33.    
  34. tv.setText(ss);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top