简体   繁体   中英

How to show JSON volley request reponse's object (in HTML) form in textView?

I have a JSON response in which object values are in HTML form. In which i have a Paragraph, a img src and video src link. How can i parse or show the image and video onto the Activity. Any help would be appreciated.

Response I'm receiving from server(only showing one object here)

{
"description":"<p>The Sarawak Ministry of Modernisation of Agriculture</p>\n
<p><video src=\"https://myurl.biz/media/media/Nokia_X3_sample_video.3gp.3gp\" autoplay=\"autoplay\" controls=\"controls\" width=\"300\" height=\"150\">
<span id=\"mce_marker\" data-mce-type=\"bookmark\">â</span></video>
</p>\n<p><img src=\"https://myurl.biz/media/media/bird_SJhLHPo.jpg\" width=\"547\" height=\"264\" /></p>" 
}

I have tried :

txtDetails.setText( Html.fromHtml(extras.getString("details"));

Actual Result I'm receiving in my text view:

The Sarawak Ministry of Modernisation of Agriculture,

​

What you're trying to do is impossible. You can't display an image/video in a TextView (this is not a browser). First, you need to parse the HTML. Then, once you have the components you can plug them in separate views. For example,

  1. You parse the HTML (there are a lot of frameworks for that)
  2. Get the image URL link and use Picasso (popular framework for displaying images from URLs) to display it on your Activity.
  3. Get the paragraph and display it in a TextView etc..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM