is it possible to put a recyclerview into another with data from retrofit 2?

Firstly, You should change your UrunAdapter.getItemCount() to return urun.size() instead of urunListeSize. It will be easy to synchronize.

You need to call the notifyDataSetChanged() in the callback. Instead of passing categories.getId(), just pass the categories object. Also you should pass the item adapter. The retrofit, once it retrieves the data, will update categories.urunListeList and notify through the adapter that the dataset changed.

onBindViewHolder code

public void onBindViewHolder(@NonNull CategoryAdapterViewHolder holder, int position) {
    categories = categoriesList.get(position);

    categories.setUrunListeList(new ArrayList<UrunListe>());

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
    rvUrunAdapter = new UrunAdapter(context, categories.getUrunListeList(), this::onSelectedUrun, urunListes.size());


    //This is not required.

    createSubCategories(context, categories, rvUrunAdapter, position);


Change the header of the ‘createSubCategories’ method accordingly.

private void createSubCategories(Context context1, Categories catId, UrunAdapter urunAdapter, int position)

Finally modify the onResponse code. Here you should not assign the callback result to categories.urunListeList. Instead you should append.


        public void onResponse(Call<UrunListe[]> call, Response<UrunListe[]> response) {

            if (response.isSuccessful()){
                 List<UrunListe> tempList = Arrays.asList(response.body());
                  //If you are planning to refresh this data, you should clear it first.
                for(UrunListe urunListe:templist)                    

                Log.d("TAG apiCall", response.message());
                Log.d("TAG apiCall", "OK ürünler");



CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top