• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright 2013 The Android Open Source Project
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17
18<sample>
19    <name>TextLinkify</name>
20    <group>Views</group>
21    <package>com.example.android.textlinkify</package>
22
23    <!-- change minSdk if needed-->
24    <minSdk>14</minSdk>
25
26    <strings>
27        <intro>
28            <![CDATA[
29            This sample illustrates how links can be added to a TextView. This can be done either
30            automatically by setting the "autoLink" property or explicitly.
31            ]]>
32        </intro>
33    </strings>
34
35    <template src="base"/>
36    <common src="logger"/>
37
38    <metadata>
39        <status>PUBLISHED</status>
40        <categories>Views</categories>
41        <technologies>Android</technologies>
42        <languages>Java</languages>
43        <solutions>Mobile</solutions>
44        <level>INTERMEDIATE</level>
45        <icon>screenshots/icon-web.png</icon>
46        <screenshots>
47            <img>screenshots/main.png</img>
48        </screenshots>
49        <api_refs>
50            <android>android.widget.TextView</android>
51            <android>android.text.util.Linkify</android>
52            <android>android.text.Html</android>
53            <android>android.text.SpannableString</android>
54            <android>android.text.style.StyleSpan</android>
55            <android>android.text.style.URLSpan</android>
56            <android>android.text.SpannableString</android>
57        </api_refs>
58
59        <description>
60<![CDATA[
61This sample illustrates how links can be added to a TextView. This can be done either
62automatically by setting the "autoLink" property or explicitly.
63]]>
64        </description>
65
66        <intro>
67<![CDATA[
68This sample demonstrates how clickable links can be added to a `TextView` in Android.
69
70This can be done in three ways:
71
72- **Automatically:** Text added to a TextView can automatically be linkified by enabling
73autoLinking. In XML, use the `android:autoLink` property, programatically call
74[android.widget.TextView#setAutoLinkMask(int)][1] using an option from
75[android.text.util.Linkify][2].
76- **Parsing a String as HTML:** See [android.text.Html#fromHtml(String)][3].
77- **Manually by constructing a [android.text.SpannableString][4]:** Consisting of
78[android.text.style.StyleSpan][5] and [android.text.style.URLSpan][6] objects that
79are contained within a [android.text.SpannableString][7].
80
81[1]: http://developer.android.com/reference/android/widget/TextView.html#setAutoLinkMask(int)
82[2]: http://developer.android.com/reference/android/text/util/Linkify.html
83[3]: http://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String)
84[4]: http://developer.android.com/reference/android/text/SpannableString.html
85[5]: http://developer.android.com/reference/android/text/style/StyleSpan.html
86[6]: http://developer.android.com/reference/android/text/style/URLSpan.html
87[7]: http://developer.android.com/reference/android/text/SpannableString.html
88]]>
89        </intro>
90    </metadata>
91</sample>
92