How open fragment from RecyclerView.Adapter

前端 未结 6 2020
暗喜
暗喜 2020-12-09 15:46

1.TabLayout

- tab1 (Fragment1)
- tab2 (Fragment2)
- tab3 (Fragment3)
     * RecyclerView + CardView (OnClick)

On CardView Clic

6条回答
  •  眼角桃花
    2020-12-09 16:19

    For moving from one fragment to another(from RecyclerView MyViewHolder class) use this

     Fragment fragment = new AttendanceFragment();
                    FragmentManager fragmentManager = ((FragmentActivity) mContext).getSupportFragmentManager();
                    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                    fragmentTransaction.replace(R.id.fragment_container, fragment);
                    fragmentTransaction.addToBackStack(null);
                    fragmentTransaction.commit();
    

提交回复
热议问题