Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What is the outcome you want for the click?</p> <p>The simplest way to do this would be to apply a <a href="http://developer.android.com/reference/android/text/style/URLSpan.html" rel="nofollow"><code>URLSpan</code></a> onto the TextView's contents, but if you want to do something other than view a webpage you can implement your own version of <a href="http://developer.android.com/reference/android/text/style/ClickableSpan.html" rel="nofollow"><code>ClickableSpan</code></a> and make the click do whatever you want.</p> <p>Edit per your comment:</p> <p>Making a ClickableSpan go to another activity is really easy, here's the start of the code you'd need for it:</p> <pre><code>public class MyURLSpan extends ClickableSpan { Class&lt;?&gt; mClassToLaunch; public MyURLSpan(Class&lt;?&gt; classToLaunch) { mClassToLaunch = classToLaunch; } @Override public void onClick(View widget) { Intent intent = new Intent(widget.getContext(), mClassToLaunch); widget.getContext().startActivity(intent); } @Override public void updateDrawState(TextPaint ds) { // If you don't want the default drawstate (blue-underline), comment this super call out. super.updateDrawState(ds); } } </code></pre> <p>Then to use it:</p> <pre><code>String longText = "your text goes here..."; SpannableString textViewContents = new SpannableString(longText); textViewContents.setSpan(new MyURLSpan(NextActivity.class), indexToStart, lengthOfClickArea, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); myTextView.setText(textViewContents); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload