This is the html element in my Strings.xml file.
<string name="five">
<![CDATA[
<HTML>
<Body>
<p>.................Some Text.......................
<br><br>Feel free to contact us at<br> <font color="#add8e6">myemailid@gmail.com</font></p>
</body>
</HTML>
]]>
</string>
Now, when the user clicks on myemailid@gmail.com, I want the yahoo mail or gmail or which ever mail application is present in the user’s phone to open up and the myemailid@gmail.com to fill up the TO : field. Is anything like this possible?
When you are setting the text you can use (assuming you have retrieved the string into a variable called text and are referenciing a TextView called textView)
When setting your layout you can also declare android:autolink=”email” on the Views holding the five string.
The description of autolink says “Controls whether links such as urls and email addresses are automatically found and converted to clickable links.” i.e. the text within the View is parsed and any (in this case) email addresses in the text are converted to clickable links.
In the case of
android:autolink="email"your other Html tags in the text wouldn’t be processed and would be display as they are above (rather than as a processed HTML document).Whereas
Html.fromHtml()will handle the HTML tags and deal with correctly formated tags.