| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Copyright 2013 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <sample> |
| <name>TextLinkify</name> |
| <group>Views</group> |
| <package>com.example.android.textlinkify</package> |
| |
| <!-- change minSdk if needed--> |
| <minSdk>4</minSdk> |
| |
| <strings> |
| <intro> |
| <![CDATA[ |
| This sample illustrates how links can be added to a TextView. This can be done either |
| automatically by setting the "autoLink" property or explicitly. |
| ]]> |
| </intro> |
| </strings> |
| |
| <template src="base"/> |
| <common src="logger"/> |
| |
| <metadata> |
| <status>PUBLISHED</status> |
| <categories>Views</categories> |
| <technologies>Android</technologies> |
| <languages>Java</languages> |
| <solutions>Mobile</solutions> |
| <level>INTERMEDIATE</level> |
| <icon>screenshots/icon-web.png</icon> |
| <screenshots> |
| <img>screenshots/main.png</img> |
| </screenshots> |
| <api_refs> |
| <android>android.widget.TextView</android> |
| <android>android.text.util.Linkify</android> |
| <android>android.text.Html</android> |
| <android>android.text.SpannableString</android> |
| <android>android.text.style.StyleSpan</android> |
| <android>android.text.style.URLSpan</android> |
| <android>android.text.SpannableString</android> |
| </api_refs> |
| |
| <description> |
| <![CDATA[ |
| This sample illustrates how links can be added to a TextView. This can be done either |
| automatically by setting the "autoLink" property or explicitly. |
| ]]> |
| </description> |
| |
| <intro> |
| <![CDATA[ |
| This sample demonstrates how clickable links can be added to a `TextView` in Android. |
| |
| This can be done in three ways: |
| |
| - **Automatically:** Text added to a TextView can automatically be linkified by enabling |
| autoLinking. In XML, use the `android:autoLink` property, programatically call |
| [android.widget.TextView#setAutoLinkMask(int)][1] using an option from |
| [android.text.util.Linkify][2]. |
| - **Parsing a String as HTML:** See [android.text.Html#fromHtml(String)][3]. |
| - **Manually by constructing a [android.text.SpannableString][4]:** Consisting of |
| [android.text.style.StyleSpan][5] and [android.text.style.URLSpan][6] objects that |
| are contained within a [android.text.SpannableString][7]. |
| |
| [1]: http://developer.android.com/reference/android/widget/TextView.html#setAutoLinkMask(int) |
| [2]: http://developer.android.com/reference/android/text/util/Linkify.html |
| [3]: http://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String) |
| [4]: http://developer.android.com/reference/android/text/SpannableString.html |
| [5]: http://developer.android.com/reference/android/text/style/StyleSpan.html |
| [6]: http://developer.android.com/reference/android/text/style/URLSpan.html |
| [7]: http://developer.android.com/reference/android/text/SpannableString.html |
| ]]> |
| </intro> |
| </metadata> |
| </sample> |