Вот как я показываю нижний лист при щелчке по элементу в представлении recyclerview
Код: Выделить всё
@Override
public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, final int position) {
myViewHolder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetFragment bottomSheetFragment = new BottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putInt("id",productList.get(position).getId());
bundle.putString("name",productList.get(position).getName());
bundle.putDouble("price",productList.get(position).getPrice());
bundle.putInt("stock",productList.get(position).getStock());
bundle.putInt("quantity",productList.get(position).getQuantity());
bundle.putString("photo",productList.get(position).getPhoto());
bottomSheetFragment.setArguments(bundle);
bottomSheetFragment.show(fragmentManager, bottomSheetFragment.getTag());
}
});
}
Объявив логическое значение, чтобы показать, отображается ли BottomSheet или нет
Код: Выделить всё
private boolean isBottomSheetShowing = false;
Код: Выделить всё
if(!isBottomSheetShowing){
isBottomSheetShowing = true;
ItemBottomSheet itemBottomSheet = new ItemBottomSheet();
Bundle bundle = new Bundle();
bundle.putString("code",itemPosition.getCode());
bundle.putString("name",itemPosition.getName());
bundle.putString("description",itemPosition.getDescription());
bundle.putString("upcCode",itemPosition.getUpcCode());
bundle.putString("photoBlob",itemPosition.getPhotoBlob());
bundle.putDouble("discount",itemPosition.getDiscount());
bundle.putDouble("price",itemPosition.getPrice());
bundle.putInt("available",itemPosition.getAvailable());
itemBottomSheet.setArguments(bundle);
itemBottomSheet.show(fragmentManager, itemBottomSheet.getTag());
}else{
isBottomSheetShowing = false;
}
Подробнее здесь: https://stackoverflow.com/questions/622 ... double-tap