Android multiple choice list dialog tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 พ.ย. 2024

ความคิดเห็น • 199

  • @adamrhoades7807
    @adamrhoades7807 3 ปีที่แล้ว

    if I am correct you code will crash still with the else if statement when you are trying to unclick an object. Int position is not the index of the integer array list but the index of your item in the dialog list. if you switch it from:
    else if (chMovieTags.contains(which)) {
    chMovieTags.remove(which);
    }
    to this:
    else if (chMovieTags.contains(which)) {
    chMovieTags.remove(chMovieTags.indexOf(which));
    }
    This is far better approach especially with user decisions unless you order the arrayList. I could be wrong though, but I would double check that. I'm still new to the development side trying to have fun. This approach is far better than trying to do an inflated menu list Great job! Saved me time and messy code

  • @eyalmedina4245
    @eyalmedina4245 6 ปีที่แล้ว +1

    Thanks for the awesome tutorials.
    Just one note:
    You clear the list mUserItems (line 77) and set the text of mItemSelected to "" (line 88) inside a loop ( doing the same thing multiple times which is unnecessary )

  • @pawanmanjule5421
    @pawanmanjule5421 7 ปีที่แล้ว +8

    Nice tut
    while removing item cast it to Integer
    mItems.remove((Integer) position);

  • @jefffame7938
    @jefffame7938 7 ปีที่แล้ว +17

    Good tutorial, but there is a flaw in your code. You have to remove the item by their index position in mUserItems, NOT by the integer value of the item in the list. Otherwise you'll get array error.
    So, when removing an item, the code should be like this:
    if (isChecked) {
    if (!mUserItems.contains(position)) {
    mUserItems.add(position);
    }
    } else {
    if (mUserItems.contains(position)) {
    mUserItems.remove(mUserItems.indexOf(position));
    }
    }

  • @vibhutikumarpathak9925
    @vibhutikumarpathak9925 6 ปีที่แล้ว +1

    Thanks for this tutorial.
    Could you please add a video on filter with multiple field with multiple choice
    thanks

  • @elizabethhayes9659
    @elizabethhayes9659 5 ปีที่แล้ว +1

    I would like to display the checkboxes immediately the app opens, and only show the 'MAKE AN ORDER' button on the second screen that displays the selected items.
    Even better, I'd like the 'Clear All' button to deselect all the check boxes while remaining in the same screen.
    Any suggestions, gentlemen?

  • @cledilsonprogramador
    @cledilsonprogramador 6 ปีที่แล้ว

    Coding Demos, How can I add Selected itens in various TextView? example:
    Food TextView: (Selected Item)
    TextView of cookies: (selected item) IS possible??

  • @two4by7
    @two4by7 4 ปีที่แล้ว

    Is it possible to keep the dialog display on when "Clear all" is touched? It should just clear the selections, but the dialog should not disappear

  • @adityarevankar6529
    @adityarevankar6529 3 ปีที่แล้ว

    what will be the context 10:14 when you are implementing this in the fragment

  • @droveinternational1950
    @droveinternational1950 3 ปีที่แล้ว

    How to define check to true by default first array? Thanks

  • @tomsfamily4201
    @tomsfamily4201 6 ปีที่แล้ว

    you're awesome sir thanks for this tutorial you save my week thanks a lot. making more videos for as.

  • @beverlynreyes6360
    @beverlynreyes6360 7 ปีที่แล้ว +1

    Hi. I did this tutorial and it works, but I need to put a value on each checkboxes whenever I checked it and send it to String and add every value I checked. How can I do that? I really need your help. Thanks.

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Hi, i'm sorry but what you are asking is already shown in the video. Is it possible if you explain in detail and you are welcome to send me your code (codingdemos@gmail.com) and i'll do my best to help you :)

  • @sarthakgupta2528
    @sarthakgupta2528 7 ปีที่แล้ว

    well done!! awesome video. step by step explantion.

  • @pradeeprai7408
    @pradeeprai7408 4 ปีที่แล้ว +1

    Thank u sir u saved my life

  • @MrDevilwing
    @MrDevilwing 7 ปีที่แล้ว +1

    hi .. how can we limit the selection count like max 4 item can be selected
    can it be down by keep track the lent of added item in the array list and if it exceed we do on onclick of multiple choice method
    Checkeditems [Position] = false ;

    • @CodingDemos
      @CodingDemos  6 ปีที่แล้ว +1

      Hi, sorry for the late reply. Yeah that can work and you also need to check whether the list have exceeded the maximum items that can be added or not like this:
      if(isChecked){
      if(mUserItems.size() < 4) {
      mUserItems.add(position);
      }else{
      checkedItems[position] = false;
      }
      }else{
      mUserItems.remove((Integer.valueOf(position)));
      }

  • @gameexperts5784
    @gameexperts5784 6 ปีที่แล้ว

    Hi! Coding Demons!
    I have created a listview by sqlite database.. Instead of making custom list in the dialog box, I want to have the list that I created by sqlite db.. So, How to load that list to dialog?

  • @surabhinalamwar6264
    @surabhinalamwar6264 4 ปีที่แล้ว +1

    Thank you very much sir, Guys refer github link for error.

  • @nokyeeching7572
    @nokyeeching7572 4 ปีที่แล้ว +5

    Removing Items Error Explanation:
    The parameter "int position" represents the checked item's position in the list: "listItems"
    (e.g. Onion = 0, Sausage = 1, Milk = 2)
    If Onion and Milk is checked
    Array: mUserItems shows [0, 2]
    Later, if we unchecked "Milk"
    the position passed to the onClick function is 2.
    But the size of Array: mUserItems is just 2, therefore no item with position 2 can be removed, and crash happened.
    Solution:
    To search the item position in Array: mUserItems with value 2, with a for loop.
    In the above case (Array: mUserItems shows [0, 2]),
    to remove "Milk (position index: 2),
    we need to remove the item of position 1 from Array: mUserItems.
    Amended Code for removing items from the checked list:
    public void onClick(DialogInterface dialog, int position, boolean isChecked) {
    if (isChecked) {
    if (!mUserItems.contains(position)) {
    mUserItems.add(position);
    }
    } else {
    for (int i = 0; i < mUserItems.size(); i++)
    if (mUserItems.get(i) == position) {
    //
    mUserItems.remove(i);
    break;
    }
    }
    }

    • @amineboumahdi6138
      @amineboumahdi6138 4 ปีที่แล้ว +1

      simply write: mUserItems.remove(mUserItems.indexOf(position))

    • @quirinoswering3137
      @quirinoswering3137 4 ปีที่แล้ว

      I really appreciate your help man, thanks alot!

    • @DevilsDaddy1
      @DevilsDaddy1 4 ปีที่แล้ว

      Hey, can you help me with the logic of prepopulating the correct checkboxes based on the indexes i store in the database for the listitems.

  • @kikachillo
    @kikachillo 5 ปีที่แล้ว

    What could be the best way to display toast when deselect checked item? For example- I select milk and then uncheck, when I do so, it display toast- "You just deselect Milk".

  • @MGimoro
    @MGimoro 6 ปีที่แล้ว

    Hmm... What if I used a checkbox as my button? How would I code it so that if an item on the array is checked, the checkbox which I used as my button would also be checked?

    • @CodingDemos
      @CodingDemos  6 ปีที่แล้ว +1

      Hi, you mean you want to replace the two buttons on the AlertDialog with checkboxes?

    • @MGimoro
      @MGimoro 6 ปีที่แล้ว

      I mean in this video, you used a Button to make the AlertDialog appear right? I want to replace that button with a checkbox that is checked when at least 1 item inside the AlertDialog is Selected, and not checked if non are selected
      This is what I did
      mAllergies = Checkbox
      mBuilder.setCancelable(false);
      mBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
      String item = "";
      for (int i = 0; i < mUserItems.size(); i++){
      item = item + listItems[mUserItems.get(i)];
      if(i != mUserItems.size() -1){
      item = item + ", ";
      }
      }
      mItemSelected.setText(item);
      if(mItemSelected.getText() == ""){
      mAllergies.setChecked(false);
      }else{
      mAllergies.setChecked(true);
      }
      }
      });

  • @udayasri3578
    @udayasri3578 5 ปีที่แล้ว

    Hi Coding Demos tutorial, i have nearly 100 items so i want to select checkbox which text i searched in search option but i getting another position text please help me as soon as possible

  • @udayasri3578
    @udayasri3578 6 ปีที่แล้ว

    how can i set some default values is checked while opening this alertdialog please tell any solution for this?

  • @TalKaboyStone
    @TalKaboyStone 5 ปีที่แล้ว

    Thank for share this!!! solved my issues!!

  • @bhavyapanchotia1218
    @bhavyapanchotia1218 4 ปีที่แล้ว

    Hello,
    I have 2 multiple choice list and the other multiple list is dependent on the selection of 1st multiple choice list. How do I implement that?

    • @CodingDemos
      @CodingDemos  4 ปีที่แล้ว

      Hi, I'm sorry but I don't know how to do it

  • @shivamjamaiwar2962
    @shivamjamaiwar2962 6 ปีที่แล้ว

    i have a list of some items, and i have to checked that item in alertdialog how can i do this please tell me thanks in advance.

  • @pallavjhaveri4168
    @pallavjhaveri4168 5 ปีที่แล้ว

    Hi, How can we add images of the checked items instead of text?

  • @annoy_gaming3358
    @annoy_gaming3358 4 ปีที่แล้ว

    sir alert dialog pr searchview lga slte hai kya??

    • @NexTechNode
      @NexTechNode 4 ปีที่แล้ว

      Did you get solution for this adding serchview on alert dialog?

  • @ExploreLifeJourney
    @ExploreLifeJourney 7 ปีที่แล้ว +1

    can i add select all option

  • @AnilYadav-tj4bl
    @AnilYadav-tj4bl 4 ปีที่แล้ว

    Nice

  • @b.k4142
    @b.k4142 6 ปีที่แล้ว

    -keys element :
    -String[ ] listItem
    - Boolean [ ]
    - mUsers = new Arrayslist( )
    - listItem = getResource
    - mBuilder.setMultiChoiseItems

  • @אופקשלו-ד8ז
    @אופקשלו-ד8ז 6 ปีที่แล้ว +1

    Q: Can you do a video how to do that with a custom listview(with photos)
    Thank you very much

  • @DekanSarwat
    @DekanSarwat 4 ปีที่แล้ว

    well done and thank you

  • @gemryan8142
    @gemryan8142 6 ปีที่แล้ว

    Hi, assuming I saved the checked items to my Firebase, how can I call the checked items from the database to the dialog and get them checked already? Thank you!

    • @mohamedredha9586
      @mohamedredha9586 2 ปีที่แล้ว

      how to collect the selected items and send them to firebase ?

  • @faysalahmedakash7703
    @faysalahmedakash7703 6 ปีที่แล้ว

    selecting all item your shown code below works and selects all the items but when i select "select all" button the dialog box doesn't stay...it vanishes.Basically i am wanting to do click select all-->click ok-->selected item shown in the textView..plz ans

    • @CodingDemos
      @CodingDemos  6 ปีที่แล้ว

      Hi, I made a video tutorial that will show you how to prevent the alertdialog from vanish: th-cam.com/video/9bzxSwqBf74/w-d-xo.html
      After you follow that tutorial and you get it working, here is the code for the select all option:
      ListView list = ((AlertDialog) mDialog).getListView(); --> write this after dialog.show();
      Inside alertdialog button onClick method you add the following code:
      mUserItems.clear();
      for(int m = 0; m < list.getCount(); m++) {
      checkedItems[m] = true;
      list.setItemChecked(m, true);
      mUserItems.add(m);
      }

  • @sudarsana1433
    @sudarsana1433 6 ปีที่แล้ว

    I want add two or more Buttons and i will make an order in different multiple choice list , Is it possible in your code

    • @CodingDemos
      @CodingDemos  6 ปีที่แล้ว

      Hi, the maximum number of buttons that you can add in multichoice dialog are 3.
      So maybe you can add those buttons outside of the dialog.

  • @soniakshay504
    @soniakshay504 7 ปีที่แล้ว

    how can i show data from database in this multiple_choice_listview ???
    help needed.

  • @chetansharma3037
    @chetansharma3037 5 ปีที่แล้ว

    can i make firebase child for each selected item

  • @farihakhalid7533
    @farihakhalid7533 5 ปีที่แล้ว

    i am getting an error can you please help! when i unchecke the check boxes the respective items are not removed and i am getting the error

  • @juanvictorbascopecastro1700
    @juanvictorbascopecastro1700 3 ปีที่แล้ว

    Those that have an error removing the position is that the position is being deleted and not the object, that is, mUserItem.remove(int) is executed and not mUserItem.remove(Object o); to resolve to declare an Integert integer - position; mUserItem.remove(integer);

  • @singhsaabsingh650
    @singhsaabsingh650 4 ปีที่แล้ว +1

    how to save checked state !

    • @CodingDemos
      @CodingDemos  4 ปีที่แล้ว

      Hi, you may use Android sharedpreference

    • @singhsaabsingh650
      @singhsaabsingh650 4 ปีที่แล้ว

      @@CodingDemos it doesn't work with it please share the code ! i want to save it whenever user click on button does changes to check list it save it for small time when again user click on that button but whenever user come on that activity it shows all checked items
      but i can do changes according to functionalty of check n uncheck but again if user click on button it shows all checked

  • @harshinisheelam8740
    @harshinisheelam8740 6 ปีที่แล้ว

    HI
    How can i select all at a time?

  • @onkarpawar494
    @onkarpawar494 3 ปีที่แล้ว

    I want to parse json array in alert dialog(Radio button list). Please help.....

    • @CodingDemos
      @CodingDemos  3 ปีที่แล้ว

      Hi, are you having any issues with parsing the data?

    • @onkarpawar494
      @onkarpawar494 3 ปีที่แล้ว

      @@CodingDemos No, issue found when I saw your video.
      But I want to parse json array in alert dialog list. If you able to do this, then please give me code.

  • @diegosolina4075
    @diegosolina4075 4 ปีที่แล้ว

    it's posible to disabled an item of the list=¿?

    • @CodingDemos
      @CodingDemos  4 ปีที่แล้ว

      Oh I'm not sure about that

  • @kberry298
    @kberry298 7 ปีที่แล้ว

    How can you code it so the clear all keeps you on the same order listview page

  • @abbywang1476
    @abbywang1476 6 ปีที่แล้ว +1

    Thank you so much!👍🏼

  • @sajadgholami1137
    @sajadgholami1137 3 ปีที่แล้ว

    nice but
    in -> (mBuilder.setNeutralButton) Maybe type (mUserItems.clear();) and (mItemSelecter.settext("");) in outside if (For) Because this operation need just one time run!
    nice try :)

  • @elizabethhayes9659
    @elizabethhayes9659 5 ปีที่แล้ว

    Can someone explain to me where the layout of the checkable list and the three buttons underneath comes from?

    • @CodingDemos
      @CodingDemos  5 ปีที่แล้ว

      Hi, the layout is part of Android resource files while those three buttons comes with Alertdialog: Positive, negative and neutral button

    • @elizabethhayes9659
      @elizabethhayes9659 5 ปีที่แล้ว

      Thanks for that clarification!

  • @machtal1980
    @machtal1980 7 ปีที่แล้ว

    Nice tutorial, but how to retrieve array from database ?

    • @gemryan8142
      @gemryan8142 6 ปีที่แล้ว

      Same question, did you get it?

  • @subratkumarrautara2460
    @subratkumarrautara2460 5 ปีที่แล้ว

    The tutorial is good, but there are so many errors, kindly update the correct one.. :-)

  • @autisticnocc7398
    @autisticnocc7398 6 ปีที่แล้ว

    mBuilder.setNegativeButton("Dismiss", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    dialog.dismiss();
    }
    });
    What does this do exactly? Does it close the the Dialog? The checkbox becomes unchecked when I dismiss it with checked values.

    • @CodingDemos
      @CodingDemos  6 ปีที่แล้ว +1

      Hi, setNegativeButton is used to set a button on the AlertDialog, while dialog.dismiss() is use to close/dismiss the whole dialog from the user screen.
      The reason those checkbox becomes unchecked is because you are not saving the values of the checkbox.
      Its best if you save the checkbox values inside setPositiveButton onClick method

  • @omkarwalujkar2914
    @omkarwalujkar2914 6 ปีที่แล้ว

    how can i add search bar?

  • @200564612434
    @200564612434 7 ปีที่แล้ว

    +Coding Demos hiiii !! how to retain the SELECTION of items after pressing the OK and again Clicking on the BUTTON ??

  • @gnasamx
    @gnasamx 7 ปีที่แล้ว

    make more videos like this..

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Sure will do, thanks for watching :)

    • @gnasamx
      @gnasamx 7 ปีที่แล้ว +2

      hey hiiii.
      your this code from in OnClick method give arrayBound error, when i selected or remove items randomly..
      your code >>>
      if(isChecked){
      if( ! mUserItems.contains(position)) {
      mUserItems.add(position);
      }
      }else
      if (mUserItems.contains(position)) {
      mUserItems.remove(position);
      }
      but i update the Onclick method..
      my code>>>
      if(ischecked){
      mUserItems.add(position);
      }else{
      mUserItems.remove((Integer.valueOf(position)));
      }
      This works fine when selected or remove Items randomly..

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Hi Ganesh, i've tested the app on emulator and it didn't crash, but when i used a physical device (Nexus 4) the app crashed with the same error that you've mentioned.
      Now when i used your code and tested the app again on my Nexus it doesn't crash anymore :D
      Thanks a lot for pointing out the error and providing the solution i really appreciate it

    • @mohammedfathemubin5591
      @mohammedfathemubin5591 7 ปีที่แล้ว

      An excellent work Ganesh...needed this to be solved badly...kudos

  • @ravikumarthirumani7354
    @ravikumarthirumani7354 5 ปีที่แล้ว

    suppose if I have multiple spinners with different values, based upon selected values I have to open the new activity So how can I do that??
    Can anyone Help me!?

  • @mugeshleo6695
    @mugeshleo6695 6 ปีที่แล้ว

    i want display json out in mutiple list dialog box help

  • @Nico_Aramy
    @Nico_Aramy 5 ปีที่แล้ว

    anyone know how to get that string-array or List item from firebase ?

  • @romansocorro3523
    @romansocorro3523 7 ปีที่แล้ว +1

    how to set it up? like, you can only check 1 item? thanks :)

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Hi, you can do it like this:
      mBuilder.setSingleChoiceItems(listItems, -1, new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialogInterface, int i) {
      }
      });
      - listItems: Is the list that contain the data
      - checkedItem: If you want to specify which item you want it to be checked, here we are setting it to (-1) because we don't want any items to be checked.
      I hope that helps :)

    • @romansocorro3523
      @romansocorro3523 7 ปีที่แล้ว +1

      its working now for the single choice items, but when I pick one and click ok it's not showing in the textview

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      You will need to put this line inside the onClick method above: mUserItems.add(i);

    • @romansocorro3523
      @romansocorro3523 7 ปีที่แล้ว +1

      thank you sir!

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Your welcome :)

  • @hectorcorniel3422
    @hectorcorniel3422 7 ปีที่แล้ว

    do anybody know how to use textview in another activity than is not in the same with that button

  • @akshayshetty145
    @akshayshetty145 7 ปีที่แล้ว +1

    hi i want use select all method in listview how can we sue that

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Hi, here is the code:
      for(int m = 0; m < mCheckedItems.length; m++) {
      mCheckedItems[m] = true;
      }

  • @MrDflego
    @MrDflego 7 ปีที่แล้ว +1

    Instead of displaying the items in a textView, how can I display the items in a listView?

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว +1

      Hi, you will need to create a listview to display those selected items and an adapter in order to hold those items for you like this:
      - Add a listview inside activity_main.xml file
      - Inside mBuilder.setPositiveButton onClick method you add the following code:
      List myList = new ArrayList(Arrays.asList(items.split(",")));
      ArrayAdapter mAdapter = new ArrayAdapter(MainActivity.this, android.R.layout.simple_list_item_1, myList);
      mList.setAdapter(mAdapter);
      I hope that helps :)

    • @MrDflego
      @MrDflego 7 ปีที่แล้ว +1

      Thanks chief, I had to play around with the loops a bit but it worked in the end, saved me.

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Your welcome :)

    • @mukeshmathur142
      @mukeshmathur142 6 ปีที่แล้ว

      Instead of displaying the items in a textView, how can I display the items in a expandable listView child group?

  • @raoamareshwar
    @raoamareshwar 7 ปีที่แล้ว +1

    can we achieve the same in recycle view

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Hi, what are you planning to do with recyclerview?

    • @raoamareshwar
      @raoamareshwar 7 ปีที่แล้ว +1

      i want to set the value of a field in recycle view row from the custom dialog input.

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Did you try to declare a variable that will hold the value from the custom dialog, then you pass that value to the field in recyclerview?

    • @raoamareshwar
      @raoamareshwar 7 ปีที่แล้ว +1

      i tried n failed with spinner. I have create a spinner onitemselection n their i was able to get the recycle row position but the challenge i was facing was from there i couldnt update the row item value.

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Please email me (codingdemos@gmail.com) the code so that i can see what is the problem

  • @MQasimCharolia
    @MQasimCharolia 7 ปีที่แล้ว +1

    how to implement Select All functionality in same example..???

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว +1

      Hi, here is the code:
      for(int m = 0; m < mCheckedItems.length; m++) {
      mCheckedItems[m] = true;
      }

    • @MQasimCharolia
      @MQasimCharolia 7 ปีที่แล้ว +1

      Coding Demos thanks....man...

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Your welcome :)

    • @faysalahmedakash7703
      @faysalahmedakash7703 6 ปีที่แล้ว

      this code works and selects all the items but when i select "select all" button the dialog box doesn't stay...it vanishes.why?plz ans

  • @ExploreLifeJourney
    @ExploreLifeJourney 7 ปีที่แล้ว

    how to get all position which i am selected

  • @bharatns598
    @bharatns598 4 ปีที่แล้ว

    How to do the same thing without using dialog box

    • @CodingDemos
      @CodingDemos  4 ปีที่แล้ว

      Hi, you can create a custom listview/recyclerview. You create an XML file where you will add a checkbox and a textview. Then you will use this file inside the adapter.

    • @bharatns598
      @bharatns598 4 ปีที่แล้ว

      @@CodingDemos I done that but my problem is getting the checkbox input and store it in array and check it with our array .
      How to do like that.

    • @CodingDemos
      @CodingDemos  4 ปีที่แล้ว

      @@bharatns598 Okay, here is an answer that may help you do it: stackoverflow.com/questions/31625730/how-to-select-multiple-checkbox-and-create-an-array-with-the-values-in-android

    • @bharatns598
      @bharatns598 4 ปีที่แล้ว

      @@CodingDemos
      Im having the doubts that now I'm creating the app that useses the multiple checkbox in the list view the checked checkbox value to be stored in array and then it need to be checked with stored values in array
      For eg:
      Boy[] = Sam, ram, john
      Girl[] = Samantha, Rose, jasmine
      Make boy and girl as an array
      Name[] = boy girl
      User clicked check box value
      Userckicked[] = Sam ram john
      Then it should check
      If(userclicked == name ) Start another activity
      Like this. i Hope i make it clear

  • @beautycenter_4331
    @beautycenter_4331 6 ปีที่แล้ว

    fatal error
    when i click again on a selected item app crash , how to solve this error??

    • @CodingDemos
      @CodingDemos  6 ปีที่แล้ว

      Hi, do you see any error message in the Logcat?

    • @beautycenter_4331
      @beautycenter_4331 6 ปีที่แล้ว

      Process: com.example.amr.elmakhzansp, PID: 28821
      there was an error i fixed it but a second one appears when is when i click over than one time ckeck remove check remove and so on app crash and error occurs
      java.lang.IndexOutOfBoundsException: Index: 4, Size: 2
      at java.util.ArrayList.remove(ArrayList.java:503)
      at com.example.amr.elmakhzansp.CreateAddActivity$1$1.onClick(CreateAddActivity.java:45)

  • @larsou331
    @larsou331 6 ปีที่แล้ว

    How can i make it RTL

    • @CodingDemos
      @CodingDemos  6 ปีที่แล้ว

      Hi, I'm not really sure if you can move the multichoice to the right side

    • @larsou331
      @larsou331 6 ปีที่แล้ว

      ok

  • @joebonino1312
    @joebonino1312 7 ปีที่แล้ว +6

    Your setMultipleChoiceItems(..) should look like
    mBuilder.setMultiChoiceItems(genresStrings, genresBoolen, new DialogInterface.OnMultiChoiceClickListener() {
    @Override
    public void onClick(DialogInterface dialogInterface, int i, boolean isChecked) {
    if(isChecked) {
    if (!mIndicesSelected.contains(i)) {
    mIndicesSelected.add(i);
    }
    }
    else if(mIndicesSelected.contains(i)){
    mIndicesSelected.remove((Integer)i);
    }
    }
    });
    This will fix if you select an item, hit ok, then deselect same item and hit ok.
    the "mIndicesSelected.remove((Integer)i);" needs to be casted or else it tries to remove at that position rather than remove that number at "some" position

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Cool thanks :)

    • @mohammedfathemubin5591
      @mohammedfathemubin5591 7 ปีที่แล้ว

      Joe thanks a lot for this minute but a much needed correction...kudos

    • @shashankmishra3003
      @shashankmishra3003 7 ปีที่แล้ว

      Thanks for the update.

    • @Lethal_Dankness
      @Lethal_Dankness 6 ปีที่แล้ว +1

      im learning to use android studio thanks for the fix i was going crazy haha

  • @stylersito
    @stylersito 7 ปีที่แล้ว +1

    close app, unselected checkbox. :/ help!

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Hi, can you please tell me what is the error message? or you can email me your code to (codingdemos@gmail.com)

    • @stylersito
      @stylersito 7 ปีที่แล้ว

      mItems.remove(position);

    • @stylersito
      @stylersito 7 ปีที่แล้ว +1

      send me pls code:
      ppepinito@gmail.com

    • @CodingDemos
      @CodingDemos  7 ปีที่แล้ว

      Hi, you can access the source code for this project at Github: github.com/codingdemos/MultichoiceTutorial

    • @stylersito
      @stylersito 7 ปีที่แล้ว +2

      solution:
      int pos = mItems.indexOf(position);
      mItems.remove(pos);

  • @anonymoustb6247
    @anonymoustb6247 5 ปีที่แล้ว

    Can you please explain:
    public void onClick(DialogInterface dialogInterface, int which) {
    String workout = "";
    for(int i = 0; i < workoutSelected.size(); i++) {
    workout = workout + listWorkouts[workoutSelected.get(i)];
    if(i != workoutSelected.size()-1){
    workout = workout + "
    ";
    }
    }
    workouts.setText(workout);
    }
    });

  • @komalardekar8337
    @komalardekar8337 5 ปีที่แล้ว +1

    i have error in isChecked

    • @CodingDemos
      @CodingDemos  5 ปีที่แล้ว

      Hi, may I know what is the error message?

    • @anonymoustb6247
      @anonymoustb6247 5 ปีที่แล้ว

      @@CodingDemos I have the error too, mine says 'error: cannot find symbol variable isChecked'

    • @anonymoustb6247
      @anonymoustb6247 5 ปีที่แล้ว

      @@CodingDemos fixed it by making a public boolean isChecked above the onCreate function however now my text view will not display the text from the selected items.

    • @anonymoustb6247
      @anonymoustb6247 5 ปีที่แล้ว

      @@CodingDemos fixed by just changing isChecked to checked.

    • @anonymoustb6247
      @anonymoustb6247 5 ปีที่แล้ว

      Also is there a way to make the checkboxes say one thing but output different text?

  • @lakshmikanth4573
    @lakshmikanth4573 4 ปีที่แล้ว

    The selected list is unable to copy

    • @CodingDemos
      @CodingDemos  4 ปีที่แล้ว

      Do you get any error message in the logcat?

    • @lakshmikanth4573
      @lakshmikanth4573 4 ปีที่แล้ว

      No but i am unable to copy the content what I have selected

    • @CodingDemos
      @CodingDemos  4 ปีที่แล้ว

      Copying the content to a textview?

    • @lakshmikanth4573
      @lakshmikanth4573 4 ปีที่แล้ว

      @@CodingDemos yes

  • @misterioaqo
    @misterioaqo 5 ปีที่แล้ว

    to fix errors: mUserItems.remove(mUserItems.indexOf(position));

  • @xpopcornx1747
    @xpopcornx1747 6 ปีที่แล้ว +1

    Wrong. All dialogs should be in a fragment.

  • @sruthisarath7342
    @sruthisarath7342 6 ปีที่แล้ว

    If I want to display recycler view of only for those which I hv selected from dialogue box.Thn hw vl I do it?can u help me