从RecyclerView适配器项目中,用ViewPager内的另一个片段替换片段单击

时间:2019-09-20 07:45:17

标签: android android-fragments android-recyclerview

我有一个包含3个片段的视图寻呼机,[2]片段包含一个RecyclerView,其中包含很多项。我的问题是,我想显示另一个[4]片段,以显示RecyclerView Adapter中的项目详细信息,并将项目的内容传递给该片段。 但是我被困在如何实现这一目标上。

  @Override
public void onBindViewHolder(@NonNull CowCardViewHolder holder, int position) {
    if (mHerdList.get(position).getSex() != null) {
        holder.mCowId.setText(String.valueOf(mHerdList.get(position).getAnimalNo()));
    } else {
        Timber.d("No items in the detail list %s", mHerdList.size());
    }


    holder.layout.setOnClickListener(view -> {
        index = position;
        notifyDataSetChanged();
    //want to Change the Fragment here and passing the item data to that fragment 

    });

请帮助我。

0 个答案:

没有答案