<?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>Sat, 17 Dec 2011 12:11:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Dhruti</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-2508</link>
		<dc:creator>Dhruti</dc:creator>
		<pubDate>Sat, 17 Dec 2011 12:11:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-2508</guid>
		<description>Hey, You can&#039;t  set your server&#039;s content in android:text of  xml file.
You have to map it through its id in your activity. then using that you have to use setText() method of TextView in your activity
Have a nice day :)</description>
		<content:encoded><![CDATA[<p>Hey, You can&#8217;t  set your server&#8217;s content in android:text of  xml file.<br />
You have to map it through its id in your activity. then using that you have to use setText() method of TextView in your activity<br />
Have a nice day <img src='http://blog.elsdoerfer.name/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pvenugopal79</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-2400</link>
		<dc:creator>pvenugopal79</dc:creator>
		<pubDate>Tue, 25 Oct 2011 07:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-2400</guid>
		<description>Hi Friend Iam New To The Android ,please send me answer for this question &quot;how to get text from server and set to android:text in Xml file&quot; dynamically.</description>
		<content:encoded><![CDATA[<p>Hi Friend Iam New To The Android ,please send me answer for this question &#8220;how to get text from server and set to android:text in Xml file&#8221; dynamically.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tuan</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-1516</link>
		<dc:creator>Tuan</dc:creator>
		<pubDate>Tue, 30 Nov 2010 10:43:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-1516</guid>
		<description>Why did you have to create a custom subclass of ClickableSpan.  Instead you can create a ClickableSpan variable:

&lt;code&gt;&lt;pre&gt;
ClickableSpan clickable = new ClickableSpan() {
				
				@Override
				public void onClick(View widget) {
		            Log.e(&quot;select text&quot;, &quot;hi&quot;);					
				}
			};
SpannableString f = new SpannableString(&quot;....&quot;) ;
f.setSpan(clickable,  x, y, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
&lt;/pre&gt;&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Why did you have to create a custom subclass of ClickableSpan.  Instead you can create a ClickableSpan variable:</p>
<p><code>
<pre>
ClickableSpan clickable = new ClickableSpan() {

				@Override
				public void onClick(View widget) {
		            Log.e("select text", "hi");
				}
			};
SpannableString f = new SpannableString("....") ;
f.setSpan(clickable,  x, y, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
</pre>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sajid</title>
		<link>http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/comment-page-1/#comment-1470</link>
		<dc:creator>sajid</dc:creator>
		<pubDate>Fri, 15 Oct 2010 08:10:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.elsdoerfer.name/?p=120#comment-1470</guid>
		<description>how can i pass text of text view from one class to another class text view in one activity on android ( when we clicked selected text then it well be passed to another class text view ) how it is possible</description>
		<content:encoded><![CDATA[<p>how can i pass text of text view from one class to another class text view in one activity on android ( when we clicked selected text then it well be passed to another class text view ) how it is possible</p>
]]></content:encoded>
	</item>
	<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&#8217;s movement method to LinkMovementMethod. Otherwise clickable span won&#8217;t work as documentation for ClickableSpan says: &#8220;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.&#8221;</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&#8217;t seem to work for me. I&#8217;m using Android 2.1 and I replaced the showDialog() you&#8217;ve used with a Log.v() and the click isn&#8217;t logging which implies that the onClick method isn&#8217;t being called at all.</p>
<p>P.S: I skipped the MovementMethod part coz I don&#8217;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&#8217;s example: &#8220;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>&#8220;;</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(&#8220;http&#8221;, offset);<br />
    			end = text.indexOf(&#8221; &#8220;, 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&#8211;;<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 &#8211; 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 &#8211; &#8220;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>&#8220;; 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>

