I want to display Items from the mysql database to my recyclerview but I dont know why it is not displaying anything
Recyclerview
Try this code .. make one method for set adapter..
private void setAdapter(){
if (likelyProblemAdapter==null){
if (!mlikelyProblems.isEmpty()) {
likelyProblemAdapter = new LikelyProblemAdapter(mlikelyProblems, this);
mRecyclerView.setAdapter(likelyProblemAdapter);
}
}
else{
likelyProblemAdapter.notifyDataSetChanged();
}
}
this method define after getting all data like this way..
try {
JSONArray jsonArray = new JSONArray(response);
for (int i=0; i<=jsonArray.length()-1; i++){
JSONObject likelyProblemJson = jsonArray.getJSONObject(i);
likelyProblem = likelyProblemJson.getString("problems");
LikelyProblems likelyProblems = new LikelyProblems(likelyProblem);
mlikelyProblems.add(likelyProblems);
mRecyclerView.setAdapter(likelyProblemAdapter);
}
setAdapter();
} catch (JSONException e) {
e.printStackTrace();
}