Skip to content
Advertisement

What’s simple code/effective code to create CheckBox Programmatically in BottomSheetDialog when click every item in RecyclerView in Android (Java)

I have 100+ item in RecyclerView. these days I have tried to create simple code/effective code to create Checkbox in BottomSheetDialog Programmatically but no success.

My goal :

  • Every item click in RecyclerView will show BottomSheetDialog with different amount checkbox. example :

when click item[0] in RecyclerView will open BottomSheetDialog with 7 checkboxes, if click item[1] in RecyclerView will open BottomSheetDialog with 286 checkboxes, or if click item [2] will open BottomSheetDialog with 200 checkboxes, and so on.

This image will describe, what I meant.

I think my goal is possible instead I create 100+ xml for every item in RecyclerView. Using for looping, array and other… if no simple/effective code for programmatically create checkbox, never mind I will create 100+ xml for every itemListener at RecyclerView

What I have tried :

I successed add single checkbox, but failed to add other checkbox. Here is my code :

Note : I commented for looping because it didn’t work. Oke, thanks all 🙂

JavaScript

Here my layout_bottom_sheet_ayat.xml

JavaScript

Thanks very much for any sugesstion and help 🙂

Advertisement

Answer

Finally I have simple code to create Checkbox Programmatically in BottomSheetDialog. So far I satisfied with this code.

I got clues:

So base on those clues, I made some changes on my code below :

JavaScript

and my layout_bottom_sheet_ayat.xml

JavaScript

So thanks all 🙂

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement