Android client obtains JSON data from the server and parses the implementation code

First, the client gets JSON data from the server

1. Using httpurlconnection

2. Using httpclient

Secondly, JSON data analysis: JSON data: [{"Id": "67", "biaoti": "g", "logo":“ http://www.nuoter.com/wtserver/resources/upload/13508741845270.png ","logoLunbo":" http://www.nuoter.com/wtserver/resources/upload/13509015004480.jpg ","yuanJia":"0","xianJia":"0"},{"id":"64","biaoTi":"444","logo": " http://www.nuoter.com/wtserver/resources/upload/13508741704400.png ","logoLunbo":" http://172.16.1.75:8080/wtserver/resources/upload/13508741738500.png ",{"id":"62","biaoTi":"jhadasd","logo":" http://www.nuoter.com/wtserver/resources/upload/13508741500450.png ","logoLunbo":" http://172.16.1.75:8080/wtserver/resources/upload/13508741557450.png ","yuanJia ":"1","xianJia":"0"}]

Final data adaptation:

1、TextView

2、ListView:

For adapters with pictures to rewrite

For image acquisition, JSON parses the string URL: "logolunbo": http://www.nuoter.com/wtserver/resources/upload/13509015004480.jpg Get picture from URL

Imageservice tool class

The above also writes the network data obtained from the URL in the aspect call of the tool class imageservice, because they are the same.

Of course, you can also write a function to get the server image in the activity class (when it is of little use)

Call:

In addition, when downloading data is very slow, create a sub thread and pass the parameters:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>