我想从Web服务中获取数据并将其加载到我的回收视图中,如果我的数据库包含30000条记录,那么它可以正常工作,但是当我当时使用大量数据时,我会得到空数据。我可以知道如何在现有的recyclerview中实现加载更多功能。
private void fetchContacts() {
jsonURL = URLs.URL_BLOOD_BANK+"associate_type=blood_bank&pincode="+pincode+"&city="+city;
JsonArrayRequest request = new JsonArrayRequest(jsonURL,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
if (response == null) {
Toast.makeText(getApplicationContext(), "Couldn't fetch the details! Please try again.", Toast.LENGTH_LONG).show();
return;
}
List<Associate_GetSet> items = new Gson().fromJson(response.toString(), new TypeToken<List<Associate_GetSet>>() {
}.getType());
// adding contacts to contacts list
contactList.clear();
contactList.addAll(items);
// refreshing recycler view
mAdapter.notifyDataSetChanged();
pDialog.dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// error in getting json
Log.e(TAG, "Error: " + error.getMessage());
Toast.makeText(getApplicationContext(), "Error: " + error.getMessage(), Toast.LENGTH_SHORT).show();
pDialog.dismiss();
}
});
RV_Search.getInstance().addToRequestQueue(request);
}