Я хочу создать bottomSheet
, где у меня есть recyclerView
. Проблема в том, что он не показывает мой recyclerview
. Где может быть проблема? Это мой bottomSheet
класс.
public class MyBottomSheetDialogFragment extends BottomSheetDialogFragment {
public static final String TAG = "ActionBottomDialog";
private Context context;
public MyBottomSheetDialogFragment(Context context) {
this.context = context;
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.layout_wishlist_move_to, container, false);
final RecyclerView recyclerView = view.findViewById(R.id.recycler_bottom_sheet_move_to);
List<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add("Birthday " + i);
}
Adapter mAdapter = new Adapter(list);
recyclerView.setAdapter(mAdapter);
return view;
}
private class Adapter extends RecyclerView.Adapter<Adapter.BottomSheetHolder> {
private List<String> myList;
private Adapter(List<String> list) {
this.myList = list;
}
@NonNull
@Override
public Adapter.BottomSheetHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(context);
return new BottomSheetHolder(inflater.inflate(R.layout.item_wishlist_bottom_sheet, parent, false));
}
@Override
public void onBindViewHolder(@NonNull Adapter.BottomSheetHolder holder, int position) {
if (myList.size() == 0) return;
holder.labelTitleCategory.setText(myList.get(position));
holder.labelImage.setImageResource(R.drawable.ic_icon);
}
@Override
public int getItemCount() {
return myList.size();
}
private class BottomSheetHolder extends RecyclerView.ViewHolder {
final TextView labelTitleCategory;
final ImageView labelImage;
public BottomSheetHolder(@NonNull View itemView) {
super(itemView);
labelTitleCategory = itemView.findViewById(R.id.title);
labelImage = itemView.findViewById(R.id.image);
}
}
}
}
А вот класс, в котором я показываю диалог.
button.setOnClickListener(v -> {
MyBottomSheetDialogFragment dialogWish = new MyBottomSheetDialogFragment(getContext());
dialogWish.show(getFragmentManager(), WishListBottomSheetDialogFragment.TAG);
});