1

I am making a list with RecyclerView, let's call it VariationList. VariationList will contains items (VariationsItem). VariationsItems will contain a title, and a RecyclerView (VariationsItemsList).

If I click on an item of VariationsItemsList, I want the following VariationsItem to refresh, and eventually add or delete some of their items.

Is there any solution to refresh a specific item from the Adapter ? Or do I need to delete all items, then add them after modification ?

I know it is pretty confusing, so here is an example of my model :

enter image description here

In red, this is the list of green items. Each green item contains a title, and a blue list.

For example, if I click on "Petit", I want to refresh the "Test" list. If I click on "Vert", I want to refresh the "Taille" list and the "Test" list, to eventually add some items, or delete some.

Mathieu
  • 1,435
  • 3
  • 16
  • 35
  • 1
    You don't update the adapter. You update the item, then notify the adapter that an item at a given position has changed. – EpicPandaForce May 24 '18 at 13:20
  • Check this: https://stackoverflow.com/questions/33176336/need-an-example-about-recyclerview-adapter-notifyitemchangedint-position-objec/38796098 – Ganesh Tikone May 24 '18 at 13:30

1 Answers1

1

you can do it in onBindView holder in recycle view adapter

    `` @Override
      public void onBindViewHolder(Viewholder holder, final int position) {


    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

    //code what ever you want to change use position
        }
    });



    });

or you can use https://github.com/greenrobot/EventBus for change any item from outside of activity

android_jain
  • 788
  • 8
  • 19