<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Clickable URLs in Android TextViews</title>
	<atom:link href="http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/</link>
	<description>Contributing back to the Google Index.</description>
	<lastBuildDate>Wed, 11 Aug 2010 13:02:07 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Sergey</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-1355</link>
		<dc:creator>Sergey</dc:creator>
		<pubDate>Sat, 31 Jul 2010 16:51:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-1355</guid>
		<description>Akash Manohar: You have to set your TextView&#039;s movement method to LinkMovementMethod. Otherwise clickable span won&#039;t work as documentation for ClickableSpan says: &quot;If an object of this type is attached to the text of a TextView with a movement method of LinkMovementMethod, the affected spans of text can be selected. If clicked, the onClick(View) method will be called.&quot;</description>
		<content:encoded><![CDATA[<p>Akash Manohar: You have to set your TextView's movement method to LinkMovementMethod. Otherwise clickable span won't work as documentation for ClickableSpan says: "If an object of this type is attached to the text of a TextView with a movement method of LinkMovementMethod, the affected spans of text can be selected. If clicked, the onClick(View) method will be called."</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akash Manohar</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-1353</link>
		<dc:creator>Akash Manohar</dc:creator>
		<pubDate>Fri, 30 Jul 2010 18:08:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-1353</guid>
		<description>The onClick event doesn&#039;t seem to work for me. I&#039;m using Android 2.1 and I replaced the showDialog() you&#039;ve used with a Log.v() and the click isn&#039;t logging which implies that the onClick method isn&#039;t being called at all.

P.S: I skipped the MovementMethod part coz I don&#039;t need it.</description>
		<content:encoded><![CDATA[<p>The onClick event doesn't seem to work for me. I'm using Android 2.1 and I replaced the showDialog() you've used with a Log.v() and the click isn't logging which implies that the onClick method isn't being called at all.</p>
<p>P.S: I skipped the MovementMethod part coz I don't need it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dhesse</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-1048</link>
		<dc:creator>dhesse</dc:creator>
		<pubDate>Sat, 03 Apr 2010 18:54:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-1048</guid>
		<description>found the solution:


		int selectionStart = textView.getSelectionStart();
		int selectionEnd = textView.getSelectionEnd();</description>
		<content:encoded><![CDATA[<p>found the solution:</p>
<p>		int selectionStart = textView.getSelectionStart();<br />
		int selectionEnd = textView.getSelectionEnd();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dhesse</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-1047</link>
		<dc:creator>dhesse</dc:creator>
		<pubDate>Sat, 03 Apr 2010 14:24:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-1047</guid>
		<description>Hello

your code works perfect. I have just a problem with getting the clicked text.
On Y Ramesh&#039;s example: &quot;This is a #test of regular expressions with http://example.com links as used in @twitter. http://twitter.com.&quot;;

How do you get the clicked text? The onClick method has the whole textview.

Oh and here is my code for wrapping http with spans and a foregroundcolor

    	int start = 0;
    	int end = 0;
    	int offset = 0;
    	if(countMatches &gt; 0){
    		while(countMatches &gt; 0){
    			// getting start and end index of the http occurences
    			start = text.indexOf(&quot;http&quot;, offset);
    			end = text.indexOf(&quot; &quot;, start);
    			offset = end;
    			f.setSpan(new InternalUrlSpan(new OnClickListener() {
    				@Override
    				public void onClick(View v) {
    					if(v instanceof TextView){
    						System.out.println(((TextView)v).getText());
    					}
    				}
    			}), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    			f.setSpan(new ForegroundColorSpan(0xFF3366FF), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    			countMatches--;
    		}
    	}</description>
		<content:encoded><![CDATA[<p>Hello</p>
<p>your code works perfect. I have just a problem with getting the clicked text.<br />
On Y Ramesh's example: "This is a #test of regular expressions with <a href="http://example.com" rel="nofollow">http://example.com</a> links as used in @twitter. <a href="http://twitter.com." rel="nofollow">http://twitter.com.</a>";</p>
<p>How do you get the clicked text? The onClick method has the whole textview.</p>
<p>Oh and here is my code for wrapping http with spans and a foregroundcolor</p>
<p>    	int start = 0;<br />
    	int end = 0;<br />
    	int offset = 0;<br />
    	if(countMatches &gt; 0){<br />
    		while(countMatches &gt; 0){<br />
    			// getting start and end index of the http occurences<br />
    			start = text.indexOf("http", offset);<br />
    			end = text.indexOf(" ", start);<br />
    			offset = end;<br />
    			f.setSpan(new InternalUrlSpan(new OnClickListener() {<br />
    				@Override<br />
    				public void onClick(View v) {<br />
    					if(v instanceof TextView){<br />
    						System.out.println(((TextView)v).getText());<br />
    					}<br />
    				}<br />
    			}), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);<br />
    			f.setSpan(new ForegroundColorSpan(0xFF3366FF), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);</p>
<p>    			countMatches--;<br />
    		}<br />
    	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-1014</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 26 Mar 2010 13:57:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-1014</guid>
		<description>Yes. You need to use a regex to find the string indices of the substrings you want to link, then concat all the different substrings with the correct Span classes - for example the InternalURLSpan shown above.</description>
		<content:encoded><![CDATA[<p>Yes. You need to use a regex to find the string indices of the substrings you want to link, then concat all the different substrings with the correct Span classes - for example the InternalURLSpan shown above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Y Ramesh Rao</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-1008</link>
		<dc:creator>Y Ramesh Rao</dc:creator>
		<pubDate>Thu, 25 Mar 2010 05:13:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-1008</guid>
		<description>Hello there i just wanted you to ask that how can this above mentioned method be used in my scenario where my requirement get solved, if I have a string like this - &quot;This is a #test of regular expressions with http://example.com links as used in @twitter. http://twitter.com.&quot;; if this an text in the TextView then I require #test, example.com, @twitter and twitter.com as separate strings and Clickable from Textview and if Clicked I require them to be handled in a custom method for giving my actions over these String, can this is be achieved.</description>
		<content:encoded><![CDATA[<p>Hello there i just wanted you to ask that how can this above mentioned method be used in my scenario where my requirement get solved, if I have a string like this - "This is a #test of regular expressions with <a href="http://example.com" rel="nofollow">http://example.com</a> links as used in @twitter. <a href="http://twitter.com." rel="nofollow">http://twitter.com.</a>"; if this an text in the TextView then I require #test, example.com, @twitter and twitter.com as separate strings and Clickable from Textview and if Clicked I require them to be handled in a custom method for giving my actions over these String, can this is be achieved.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
