0

Hi I cant get my link clickable. What is it I'm doing wrong? The >This app< is blue and underlined but not clickable.

<string name="footer"><a href="http://google.com">This app</a> is cool</string>

this is my string in XML

<TextView
    style="@style/ContentGroupTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:autoLink="web" 
    android:text="@string/footer" />
Onik
  • 19,396
  • 14
  • 68
  • 91
Alex
  • 13
  • 1
  • 4

3 Answers3

0

If you want to add HTML-like link, all you need to do is:

add a resource HTML-like string:

<string name="link"><a href="https://www.google.pl/">Google</a></string>

add your view to the layout with NO link-specific configuration at all:

<TextView
    android:id="@+id/link"
    android:text="@string/link" />

add appropriate MovementMethod programmatically to your TextView:

 mLink = (TextView) findViewById(R.id.link);
 if (mLink != null) {
   mLink.setMovementMethod(LinkMovementMethod.getInstance());
 }
Lokesh
  • 5,180
  • 4
  • 27
  • 42
  • add appropriate MovementMethod programmatically to your TextView... where do I fill this code? In which file? – Alex Apr 10 '14 at 13:40
0
    Try this..
     <string name="about">
    <![CDATA[
    <html>
    <head></head>
    <body style="text-align:justify;">
        <a href="http://google.com">This app</a>
    </body>
    </html>
    ]]>
</string>

    tv.setText(Html.fromHtml(getString(R.string.about)));
Karthik
  • 2,282
  • 2
  • 22
  • 23
0

Please replace android:autoLink = "web" to All. It may help you..

               <TextView
                style="@style/ContentGroupTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                 android:autoLink="all" 
                android:text="@string/footer" />
SAURABH_12
  • 2,262
  • 1
  • 19
  • 19