Android spinner in custom dialog

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

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

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

    Dude thank you. Spinners have got to be the most convoluted impossible to understand thing out there.

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

    Thank you so much, you save my day, i've been frustrated to build an spinner outside the oncreate method, then i realized from your video it need some view inflater, thank you so much

  • @nour99kk21
    @nour99kk21 7 ปีที่แล้ว +3

    very helpful thankyou!
    what do i do if i want to make more than one button that has a spinner?
    like two buttons both with spinners?

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

      Hi, you can add another button and follow the steps that i showed in the video.
      I want to ask you is the second spinner that you want to add related to the first spinner? If they are, then i will suggest you to add 2 spinner in one dialog instead of having 2 dialogs with 2 spinners.
      For example: You have 1 spinner that contain list of restaurant inside a dialog and another spinner that contain list of dishes inside another dialog..that will make it kind of complicated for the user to make a choice, instead you can just add those 2 spinner under one dialog which will make it very easy for the user and less troublesome.
      Happy coding :)

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

      Like coding demos said, but be aware if you want to add more than one of those kinda items(Spinners, Edittexts and textviews, etc etc), you might end up having to create your own layout, then add in those items to that kayout, and then add the layout to the dialog
      eg:
      LiniarLayout layout = new LiniarLayout(v.getContext());
      //create your spinners (using spinner_1 and spinner_2 as example)
      layout.setView(spinner_1);
      layout.setView(spinner_2);
      //Assuming you called your dialog dialog_1
      dialog_1.setView(layout);
      Else only one spinner will be shown

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

    Thank you so much) Best video about dialog spinner!

  • @DmytroDudka
    @DmytroDudka 7 หลายเดือนก่อน

    I'm gladly thankfull that i found out your video, it helps me a lot. I appreciate your work, THANKS!!!

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

    Thanks for the tutorial! I've learned a lot...
    Is there any way to change the color of the spinner text?
    For example: Macdonald --> red color and Burger King in green color.

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

    Thank you so much!!!! You saved my life. My research project is alive thanks to you. Awesome and useful tutorial!

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

      You're welcome. I'm happy to help 😀

  • @Danielp-iu1ey
    @Danielp-iu1ey 4 ปีที่แล้ว

    Thank you very much, you just saved my thesis!!

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

    Thank you very much...really helpful tutorial..keep it up!!

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

    Sir how can I add those items from spinner to my database then view it in a different fragment?

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

    Thanks
    your tutorial its so useful

  • @Kate-dk3hq
    @Kate-dk3hq ปีที่แล้ว

    Thank you so much!

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

    nice.. easy to understand

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

      I'm happy to hear that :)

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

    you just solved my life, thanks bro

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

    Thanks Great Effort

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

    Thank you .Awesome explanation and very helpful for me.

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

    Thanks! Very clear and simple

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

    can you show how can go to new page when i click the item on the spinner?

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

      Hi, You can do it like this:
      mBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialogInterface, int i) {
      if(!mSpinner.getSelectedItem().toString().equalsIgnoreCase("Choose a restaurant…")) {
      startActivity(new Intent(MainActivity.this, SecondActivity.class));
      dialogInterface.dismiss();
      }
      }
      });
      Happy coding :)

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

    Why i get some error in line mSpinner.setAdapter(adapter); ??

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

    Nice tutorial.
    Thank you!

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

      Your welcome :)

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

      If I wanted to add dynamically other components to this custom dialog/layout, how could I do that?
      Hope you can help me!

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

    You saved my life thanks

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

      Your welcome, I'm happy to help :)

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

    Thank You sooooo much

  • @김철수-r1c
    @김철수-r1c 6 ปีที่แล้ว +1

    Really helpful to me. thanks.

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

    Great one,thank You.

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

    What abbout if I want to do this with Kotlin

  • @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!?

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

    hi sir i'm a new creator in android studio, but i have some problem there.. that's very hard to me because i need to change or switch the activity after choose and click yes/ok, can you help me sir ?
    so it is not just make some toast, but for switch the activity too.. thanks sir

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

      Hi, just add the following code inside the button OnClick method:
      startActivity(new Intent(MainActivity.this, NewActivity.class));

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

    how to show spinner value using SQLite database

  • @vadlurivivek3310
    @vadlurivivek3310 8 ปีที่แล้ว

    Nice dude! keep up the good work

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

      Thanks for watching :)

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

    awesome

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

    gracias

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

    Key statement never forget :
    - setDrop
    - if (mspinner.getSelectedItem.toString().equalsIgnoreCase() { ....}
    - mBuilder.setView(mView)
    - mBuilder.create()

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

    i am having error in "mspinner" and "DialogInterface" ,i am using android studio version 3.0.1.

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

      Hi, what is the error that you see?

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

    Very Nice.
    How to validate a spinner

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

      Hi, you can email (codingdemos@gmail.com) me your code.

  • @MK-vg5ht
    @MK-vg5ht 6 ปีที่แล้ว

    good video

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

    thanks

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

    How do you display the chosen value into a textview instead of a toast?

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

      Hi, so let's say we want to show the chosen value in a textview inside the dialog..here are the steps:
      - Open dialog_spinner.xml file and create a simple textview like this:
      - Open MainActivity.java file and define the textview inside onClick method like this:
      TextView mValue = (TextView)mView.findViewById(R.id.textview);
      - Inside mBuilder.setPositiveButton onClick method you set the chosen value inside the new textview that we've just created like this:
      mValue.setText(mSpinner.getSelectedItem().toString());
      - Don't forget to remove dialogInterface.dismiss() from mBuilder.setPositiveButton onClick method to be able to see the chosen value, otherwise the dialog will be dismissed and you won't be able to see the chosen value
      That's it..i hope that answer your question, please do let me know if you need more help.
      Thanks and happy coding :)

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

      Thank you!

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

      Your welcome :)

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

    where is the source code ????

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

      Hi, I'm sorry I didn't put the source code on Github back then. You can let me know if you are having any issues with code and I'll try my best to help you out :)

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

    falto el setVIew(mView);

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

    How to position text so it does not go over the background.
    i.stack.imgur.com/YlGPO.png

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

      You can add this line to position it below the background:
      android:layout_below="@+id/background"