If I have a textview with spanned text obtained from Html.fromHtml(source), how to make the textview to react when I click on a link? In my textview, link is something like "click here" and this text is a link, it's not a direct link like www.google.com.
            Asked
            
        
        
            Active
            
        
            Viewed 6,749 times
        
    1
            
            
        - 
                    it seems that this is an android os bug. http://code.google.com/p/android/issues/detail?id=2219 – Buda Gavril Mar 22 '11 at 15:29
- 
                    [Click this one, it's good for you][1] [1]: http://stackoverflow.com/questions/4790746/links-in-textview/13765953#13765953 – sonida Jul 11 '13 at 06:35
4 Answers
6
            
            
         android:autoLink="web"
 
    
    
        Nimantha
        
- 6,405
- 6
- 28
- 69
 
    
    
        Rohit Mandiwal
        
- 10,258
- 5
- 70
- 83
- 
                    1Yes it works. Put that on your TextView, and android:linksClickable="true" – Derzu May 25 '12 at 23:15
0
            
            
        I guess you want to handle span click event by yourself.
There two ways for this:
1)Create new class extends URLSpan
2)Create new class extends LinkMovementMethod
Please see below url, may be help you.
https://stackoverflow.com/a/16182500/596555
 
    
    
        Community
        
- 1
- 1
 
    
    
        boiledwater
        
- 10,372
- 4
- 37
- 38
0
            
            
        Butter to use Linkify
Refer Android Text Links Using Linkify 
 
    
    
        Labeeb Panampullan
        
- 34,521
- 28
- 94
- 112
- 
                    but my source code contains html tags... So, to use linkify, I need to get rid manually of these tags and linkify manually all ex link tags... isn't there a simple way? – Buda Gavril Mar 22 '11 at 09:50
0
            
            
        Add this to your tetView
android:text="@string/Documentation
Add this line to string.xml [ res/values]
<string name="Documentation"><a   href="https://developer.android.com/guide/components/activities/activity-lifecycle">Android Activity Lifecycle Documentation</a> 
</string>
Add This code to your MainActivity.java
TextView textView = findViewById(R.id.textView);      textView.setMovementMethod(LinkMovementMethod.getInstance());
 
    
    
        Adeeksha Sathsara
        
- 163
- 1
- 9
