is it possible to parse a string with html tags (like br,  , the accented letters, ..) without parsing the image tag ? If yes , how can i do It?
            Asked
            
        
        
            Active
            
        
            Viewed 1,258 times
        
    2
            
            
        - 
                    no it's not a duplicate, with fromHtml i get a string fully parsed from Html, i want to parse all html tags except the img tag – Francesco Stranieri Apr 10 '14 at 12:57
3 Answers
1
            
            
        Depends on what you are going to do with that parsed string. If you need to display it in a TextView, then you could use
textView.setText(Html.fromHtml(yourString, customImageGetter, null));
Where customImageGetter is your subclass of Html.ImageGetter which returns empty drawables in getDrawable(String source) method. Empty drawable could be an 1x1 transparent image.
 
    
    
        Const
        
- 976
- 7
- 11
0
            
            
        Define the html string in strings.xml and use this
<string name="about">
    <![CDATA[
    <html>
    <head></head>
    <body style="text-align:justify;">
    </body>
    </html>
    ]]>
tv.setText(Html.fromHtml(getString(R.string.about)));
 
    
    
        Karthik
        
- 2,282
- 2
- 22
- 23
- 
                    it's for messages, like chat, so i can't have a strings.xml about it – Francesco Stranieri Apr 10 '14 at 13:24
- 
                    check out this sample from google http://developer.android.com/samples/TextLinkify/index.html – Karthik Apr 14 '14 at 14:26
0
            
            
        I guess this would work.
1. Initially, in the html tags instead of using <img> </img>, you will have to use <image> </image>
strTemp ="<h2>Title</h2><br><p>Description here</p> <image src='source here'></image>";
2.
Spanned sp = Html.fromHtml( strTemp );
3.
textView.setText(sp.toString().replace("image", "img"));
 
    
    
        ngrashia
        
- 9,869
- 5
- 43
- 58
