Android 在具有RecyclerView的网格视图中将Json数据解析为
我指的是这首芭蕾舞。我想在此网格视图中从服务器获取json数据。请告诉我如何解析数据。另外,我需要缓存这些图像..使用截击库之类的。Android 在具有RecyclerView的网格视图中将Json数据解析为,android,json,gridview,android-recyclerview,Android,Json,Gridview,Android Recyclerview,我指的是这首芭蕾舞。我想在此网格视图中从服务器获取json数据。请告诉我如何解析数据。另外,我需要缓存这些图像..使用截击库之类的。 你能为我们的图图提供任何链接吗???请建议我使用凌空截击快速解析您的数据,可以这样实现: 创建类截击服务 公共级截击{ private static VolleyService instance; private RequestQueue requestQueue; private ImageLoader imageLoader; private VolleyS
你能为我们的图图提供任何链接吗???请建议我使用凌空截击快速解析您的数据,可以这样实现: 创建类截击服务 公共级截击{
private static VolleyService instance;
private RequestQueue requestQueue;
private ImageLoader imageLoader;
private VolleyService(Context context) {
requestQueue = Volley.newRequestQueue(context);
imageLoader = new ImageLoader(requestQueue, new ImageLoader.ImageCache() {
private final LruCache<String, Bitmap> cache = new LruCache<String, Bitmap>(20);
@Override
public Bitmap getBitmap(String url) {
return cache.get(url);
}
@Override
public void putBitmap(String url, Bitmap bitmap) {
cache.put(url,bitmap);
}
});
}
public static VolleyService getInstance(Context context) {
if (instance == null) {
instance = new VolleyService(context);
}
return instance;
}
public RequestQueue getRequestQueue() {
return requestQueue;
}
public ImageLoader getImageLoader() {
return imageLoader;
}
VolleyService.getInstance(this.getContext()).getRequestQueue();
StringRequest request = new StringRequest(url, new
Response.Listener<String>() {
@Override
public void onResponse(String response) {
// we got the response, now our job is to handle it
try {
updateArticleData(response, syncResult,categoryID);
} catch (RemoteException | OperationApplicationException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//something happened, treat the error.
Log.e("Error", error.toString());
}
});
queue.add(request);
private SomeClass getDataFromJson(String json) {
//Do sth with json
return someData;
}