I am calling wcf restful webservices from android application.I am successfully posting data to webservice and receiving response from webservice using JSON Object.
Now I need to show data开发者_如何学编程(dataset) received from webservice,on my android application in gridview.
Please help me by providing some tutorials or links to do the same.
Thanks
Seeing that you already have a REST(JSON) you can use a JSONObject.
You get the json from the REST and load it into JSONObject and then take the JSONObject and convert it into a specific object. And then take the list of object and bind it.
Reference
Tutorial
JSONObject obj = "From REST Request"
try {
JSONArray users = obj.getJSONArray("users");
for (int i = 0; i < users.length(); i++) {
User user = new User(users.getJSONObject(i));
}
} catch (JSONException e) {
e.printStackTrace();
}
class User {
private String _username;
private String _displayName;
public User() {
}
public User(JSONObject obj) {
if (obj == null)
return;
try {
setUsername(obj.getString("username"));
setDisplayName(obj.getString("displayname"));
} catch (JSONException e) {
e.printStackTrace();
}
}
public String getUsername() {
return _username;
}
public void setUsername(String _username) {
this._username = _username;
}
public String getDisplayName() {
return _displayName;
}
public void setDisplayName(String _displayName) {
this._displayName = _displayName;
}
}
精彩评论