My Recyclerview is not showing anything

前端 未结 5 1891
自闭症患者
自闭症患者 2021-01-23 13:35

I want to display Items from the mysql database to my recyclerview but I dont know why it is not displaying anything

Recyclerview



        
5条回答
  •  孤街浪徒
    2021-01-23 14:14

    Issue no 1 :- set adapter outside the loop

    Issue no 2 :- you forgot to notify your likelyProblemAdapter after adding new data in your mlikelyProblems

    Issue no 3 :- layout

    Try this

      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);\
         likelyProblemAdapter.notifyDataSetChanged();
    

    Change your layout like this

    
    
    
       
    
          
      
    
    
    
    

提交回复
热议问题