How to get child view from RecyclerView?

前端 未结 11 1936
离开以前
离开以前 2020-12-24 08:18

I am trying to get child view by position. I could get view when one item is clicked:

rvSellRecords.addOnItemTouchListener(new RecyclerItemClickListener(         


        
11条回答
  •  执念已碎
    2020-12-24 09:09

    now I understand your problem. you need to use interface for join recyclerview item and activity. you must define an interface class like below:

    public interface IViewClick {
        public void onClickButtonAdd();
    }
    

    add this parameter to your adapter class:

    private IViewClick mListener;
    

    and initialize it in constructor with value that get from inputs. when user click on PLUS button, you send event to activity by this line:

     mListener.onClickButtonAdd();
    

    in your activity class you must implements IViewClick interface and add your code there, like this:

    @Override
        public void onClickButtonAdd() {
             ///  TODO every thing that you want.
             /// change your toolbar values.
        }
    

    it is not good solution for you.

    RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForItemId(mAdapter.getItemId(i));

提交回复
热议问题