I am creating app where I implemented a BottomSheetDialogFragment to be open from inside of other fragment this work fines.
But now I want that same BottomSheetDialogFragment to be open from my adapter class which extend FirebaseRecyclerAdapter but not getting the way how to open from there.
Here is my adapter class code:
public class updateRoomAdapter extends FirebaseRecyclerAdapter<model,updateRoomAdapter.myViewHolder> {
public updateRoomAdapter(@NonNull FirebaseRecyclerOptions<model> options) {
super(options);
}
@Override
protected void onBindViewHolder(@NonNull myViewHolder holder,final int position, @NonNull model model) {
holder.id.setText("Room Id:"+model.getRoomId());
holder.description.setText("Description: "+model.getDescription());
holder.ac.setText("AC: "+model.getAC());
holder.rent.setText("Rent: "+model.getRent());
holder.nob.setText("No.of Beds: "+model.getNumber_of_beds());
Glide.with(holder.img.getContext()).load(model.getImageUrl()).into(holder.img);
holder.edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UpdateRoomFragment updateRoomFragment=new UpdateRoomFragment();
updateRoomFragment.show(getSupportFragmentManager(),updateRoomFragment.getTag());//this line showing error because getSupportFragmentManager() cannot be use here
}
});
}
@NonNull
@Override
public myViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.updatesinglerow,parent,false);
return new updateRoomAdapter.myViewHolder(view);
}
class myViewHolder extends RecyclerView.ViewHolder {
CircleImageView img;
ImageView edit;
TextView id,description,rent,ac,nob;
public myViewHolder(@NonNull View itemView) {
super(itemView);
img=(CircleImageView) itemView.findViewById(R.id.img1);
id=(TextView) itemView.findViewById(R.id.nametext);
description=(TextView) itemView.findViewById(R.id.coursetext);
rent=(TextView) itemView.findViewById(R.id.rent);
ac=(TextView) itemView.findViewById(R.id.ac);
nob=(TextView) itemView.findViewById(R.id.bed);
edit=(ImageView)itemView.findViewById(R.id.imageView2);
}
}
}
How to solve this issue?
Hi RIZWAN ALI Please Use this code
val updateRoomFragment = CreateEventBottomsheet()
updateRoomFragment.show(
(viewHolder.itemView.context as AppCompatActivity).supportFragmentManager,
updateRoomFragment.getTag()
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.