ViewPager + RecyclerView issue in android

前端 未结 3 441
逝去的感伤
逝去的感伤 2020-11-28 16:58

Hi I have Tablayout with Viewpager and i am using Fragment for tablayout. Now in every Tablayout fragments I have Recyclerview

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 17:40

    this is the main logic of your code I guess... Try it and let me know if you need more help or you find it helpful...

    private void parseJsonData() {
        try {
            listDogs.clear();
            JSONArray jsonArray = new JSONArray(loadJSONFromAsset());
            JSONObject firstJsonobject = jsonArray.optJSONObject(0);
            JSONArray itemListJsonArray = firstJsonobject.optJSONArray("itemList");
            JSONObject secondJsonobject = itemListJsonArray.optJSONObject(0);
            JSONArray typeMasterArray = secondJsonobject.optJSONArray("typeMaster");
            JSONObject thirdJsonobject = typeMasterArray.optJSONObject(0);
            JSONArray catMasterArray = thirdJsonobject.optJSONArray("catMaster");
            for(int i=0; i

    Note: To parse data for dogs category I've passed 0 position in variable thirdJsonobject. Pass 1 for cats and 2 for horse and you will find your desired output

    Screenshots: Dogs category

    Cats category

    Horse category

提交回复
热议问题