title: Capture http link click event in android textview
body: <p>I have a link in android textview. I am not able to capture the link click event.</p>
  
  <pre><code>String text = "http:://www.google.com is a google link";
  textview.setText(text);
  </code></pre>
  
  <p>"http:://www.google.com" this span of string is clickable in textview. I want to capture that particular click event.</p>
  
  <p>I tried the following.</p>
  
  <pre><code>public static void setTextView(TextView text, CharSequence sequence) {
      UoloLogger.i(TAG, "Setting string :: "+sequence);
      SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
      URLSpan[] urls = strBuilder.getSpans(0, sequence.length(), URLSpan.class);
      for(URLSpan span : urls) {
          makeLinkClickable(strBuilder, span);
      }
      text.setText(strBuilder);
      text.setMovementMethod(LinkMovementMethod.getInstance());
  }
  
  public static void makeLinkClickable(SpannableStringBuilder strBuilder, final URLSpan span) {
      int start = strBuilder.getSpanStart(span);
      int end = strBuilder.getSpanEnd(span);
      int flags = strBuilder.getSpanFlags(span);
      ClickableSpan clickable = new ClickableSpan() {
          public void onClick(View view) {
              UoloLogger.i(TAG, span.getURL());
          }
      };
      strBuilder.setSpan(clickable, start, end, flags);
      strBuilder.removeSpan(span);
  }
  </code></pre>
  
  <p>I started setting text into my textview using setTextView() method. I am getting URLSpan array is empty even if i am having the links. </p>
  
  <pre><code>String text = "http:://www.google.com is a google link";
  setTextView(textView, text);
  </code></pre>
  
  <p>Sorry for the bad english. I think, i have explained my problem. Can someone help me. </p>