In ViewHolder
, I can't call getSupportFragmentManager
.
I want to change between Fragment
I searched all of the google page. but I can't find it.
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public ImageView imgThumbnail;//img
public TextView tvspecies; //text
public ViewHolder(View itemView) {
super(itemView);
imgThumbnail = (ImageView)itemView.findViewById(R.id.img_thumbnail);
tvspecies = (TextView)itemView.findViewById(R.id.tv_species);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View v) {/*버튼 실행했을때 실행부분*/
Fragment fm=new NewsFragment();
FragmentTransaction transaction=fm.getFragmentManager().beginTransaction();
transaction.replace(R.id.Linearcontainer, fm);
transaction.addToBackStack(null);
transaction.commit();
}//onClick
}//ViewHolder
Try this one
public HorizontalProductAdapter(Activity context, List<RecycleIndividualProduct>data, FragmentManager fragmentManager){
inflater = LayoutInflater.from(context);
this.subActivityData = data;
this.fragmentManager=fragmentManager;
}
and call your adapter from your activity or fragment
mAdapter = new HorizontalProductAdapter(getActivity(),allDeals,getFragmentManager());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With