单击第一个回收器视图项目单击时调用第二个回收器视图数据

时间:2019-02-13 08:45:36

标签: android android-recyclerview

我有两个回收站视图,一个接一个。我想在“第一个回收者视图”的项目单击上加载“第二个回收者视图”数据的每个子项目。我正在使用自定义的RecyclerTouchListener加载数据。请让我知道正确的解决方案。

预先感谢

recyclerView.addOnItemTouchListener(new RecyclerTouchListener(this, recyclerView, new RecyclerTouchListener.ClickListener() {
        @Override
        public void onClick(View view, int position) {

            Product allEventDatum = productList.get(position);

            categoryss = allEventDatum.getCategory();


        }

        @Override
        public void onLongClick(View view, int position) {

        }
    }));

1 个答案:

答案 0 :(得分:0)

  

尝试一下:

recyclerViewOne.addOnItemTouchListener(new RecyclerTouchListener(this, recyclerView, new RecyclerTouchListener.ClickListener() {
    @Override
    public void onClick(View view, int position) {

        Product allEventDatum = productList.get(position);
        categoryss = allEventDatum.getCategory();

        // get your first item from first recycler view and save it in string/int
        // then pass that stored value to your API to get data according to get relevant data in the second recycler view

    }

    @Override
    public void onLongClick(View view, int position) {

    }
}));