Android custom dialog - Create Android Alertdialog with a custom layout

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

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

  • @miles2code366
    @miles2code366 7 ปีที่แล้ว +14

    You are different to most teachers on TH-cam. And that is a good thing.
    People teaching how to do stuff often forget to explain why they are writing this piece of code, you explain it all. AND It's great.
    I've subscribed + thanks!

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

      Hi Thomas, thanks a lot for the kind words...i'm really happy that you found my videos helpful
      Thanks for watching and subscribing :)

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

    Thank you soo much! I spent long long time trying to understand why I couldnt access my views without relating them into the inflate Layout using mView ! And then Bingo, finally I found your video and you helped me a lot with this!

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

      I meet an error in this example
      attempt to invok oncllikListener on a null obect refrence

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

      Hello@@walidpivano117 , in this case I would ask myself the following: 1.Did I really create a view in my XML popup file? Did I give it an id? Did I call it as said in the video by using the ".view" before the findViewById(ex TextView textView = view.findViewById(R.id.myTextViewId); Did I set the view with alertDialog method setView? example: alertDialog.setView(view); Finally did I type alertDialog.show()? I hope my own questions can help you to resolve your 'null object reference'. Good luck!

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

      Ohhh thanks man
      Because of you I find my error thats was so helpful i forgot v.find...
      Thanks you 💪❤

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

    maaaaaa negga. You're like Jesus to me right now. You don't know how much this has been helpful. Thanks!

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

      Awesome i'm glad you found it helpful :)

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

    I wanted to hit 1k likes but Unfortunately i only had thumb up
    Thankyou and that one was amazing helpful nd easiest explained video

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

      hahaha..Thanks for watching :)

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

    Thanks, I don't understand your language but it helped me a lot.

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

    Great explaining and good example. Great job! I feel like am watching paid content.

  • @Daniel-go7lx
    @Daniel-go7lx 6 ปีที่แล้ว

    Thank you so much! This tutorial was very intuitive, easy to follow, and easily applied to other situations. I used it with a ListView.

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

    WAWWW this tutorial os soooo good. Thanks a lot, i was lokking for exactly this tutorial

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

      Cool, i'm glad to hear that :)

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

    Awesome job dude! You explain very well

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

    Thanks a lot. Respect from Mexico.

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

    Thank you very much, great tutorial!.
    How to controller disapper buttons in rotation lanscape.

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

    You could use preview rather than going to design view every time to check the design.

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

      Cool thanks for pointing that out :) i'll use it next time

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

    terima kasih. penerangan yang amat bagus sekali.

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

    this is a great tutorial the only thing i wish you would show is how to close the alertdialog after successful login

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

      Right Way Entertainment Ajay Sajeev declare the Alert Dialog as a Global Variable and inside the onClickListener type the name of the global Variable and put the cancel button
      // Global Variable
      AlertDialog ad;
      ........
      onClick{
      ad.cancel
      }
      You surely need to look up at Stack overflow....Even I checked it.

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

    i really love your tutorials easy to learn . thanks for this :)

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

    Danke Lieber GOTT.... greetings from germany

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

    Really an awesome explaination,w want more tutorial from you, thanks

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

    Thanks sir that was clear and helpful tutorial

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

    I know this is an old video but great tutorial!

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

    This worked wonderfully. Thanks!

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

    Thanks! this one is very helpful. and you just got one new subscriber :)

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

    Thanks a lot. Your explanation is so great.
    Just one doubt, how can I dismiss this dialog, please?

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

      To dismiss the dialog you just call dialog.dimiss(). For example if you want to dismiss the dialog when the user have successfully filled email, password field and clicks on "Login button" you do it like this:
      - First you show the dialog like this:
      final AlertDialog dialog = mBuilder.create();
      dialog.show();
      - Then you call setOnClicklistener for the login button like this:
      mLogin.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      if(!mEmail.getText().toString().isEmpty() && !mPassword.getText().toString().isEmpty()){
      Toast.makeText(MainActivity.this,
      R.string.success_login_msg,
      Toast.LENGTH_SHORT).show();
      dialog.dismiss();
      }else{
      Toast.makeText(MainActivity.this,
      R.string.error_login_msg,
      Toast.LENGTH_SHORT).show();
      }
      }
      });
      Happy coding :)

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

      Coding Demos Tks só much, man ;)

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

      did it work for you

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

    Great video!
    Just one question. I changed the font on my edit texts from the custom dialog layout, but I want to change the font of the dialog title and the positive/negative buttons. Is there a way to do that? Also I would like to create a radius for the dialog box!
    Thank you

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

    Thank you very much, very good explanation!

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

      Thanks for watching :)

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

    Great tutorial ...... Thanks my friend

  • @AMeier-cp6bi
    @AMeier-cp6bi 7 ปีที่แล้ว +1

    Thanks very much for the great tutorial. I still wonder how I can wait
    for the dialog to be dismissed and then access and use the input for
    Email and Password? That would help me a lot!

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

      Hi, if i understand your question correctly the dialog will not be dismissed unless you actually write the code for it.
      For example you can dismiss the dialog when the user have successfully entered the email and password then you call dialog.dismiss()
      Based on the example provided in the video you can call dialog.dismiss after the successful login toast message which will hide the dialog.
      I hope that answered your question :)

    • @AMeier-cp6bi
      @AMeier-cp6bi 7 ปีที่แล้ว

      Sorry, my question was not precise enough. The functionality you describe works fine and the dialog is properly dismissed. But AFTER dismissing the dialog I need to use the input from within the dialog in the "calling program".
      Problem 1: the calling program doesn't wait for user input and dismissal
      Problem 2: i can't get the email/password-input out of the inner onClick-method and pass it to the calling program
      my current code:
      (...)
      String password;
      Button mShowDialog = (Button) findViewById(R.id.btnShowDialog);
      mShowDialog.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
      View mView = getLayoutInflater().inflate(R.layout.dialog_login,null);
      final EditText mEmail = (EditText) mView.findViewById(R.id.etEmail);
      final EditText mPassword = (EditText) mView.findViewById(R.id.etPassword);
      Button mLogin = (Button) mView.findViewById(R.id.btnLogin);
      mBuilder.setView(mView);
      final AlertDialog dialog = mBuilder.create();
      dialog.show();
      mLogin.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      if (!mEmail.getText().toString().isEmpty() &&
      !mPassword.getText().toString().isEmpty()) {
      Toast.makeText(MainActivity.this, R.string.success_login_msg, Toast.LENGTH_SHORT).show();
      dialog.dismiss();
      } else {
      Toast.makeText(MainActivity.this, R.string.error_login_msg, Toast.LENGTH_SHORT).show();
      }
      }
      });
      password = mPassword.getText().toString();
      }
      });
      Toast.makeText(MainActivity.this,"Passwort ist "+password, Toast.LENGTH_SHORT).show();
      The Toast-Command displays right at startup of the app, even before the alert
      diaglog is created. This code doesn't even compile because any variable
      (like password) from within the inner onClick method isn't visible in the
      last line of code or it is not accessible in the onClick method.
      Help!

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

      hi did you ever figure it out

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

      When you add the dialog.dismiss() an error happens saying that it can not resolve symbol. I am having the same issue as A. Meier where after everything is successfully done, I am not sure as to how close the dialog. If you could elaborate on what you said you give some insight on how to solve this problem that would be great.

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

    Thank you this is easy than I expected

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

      Thanks for watching :)

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

    nice ty ,, just what i needed ,,
    you explain very well

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

      Thanks for watching :)

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

    Ajudou muito, muito obrigado pela explicação simples e efetiva, me inscrevi no canal para acompanhar as novidades.

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

    Thanks for this. great job, man

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

    how to dismiss after login button clicked because there is not any method to dismiss that dialog???

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

    key statement
    - getLayoutinflater
    - mBuilder.setView(mView)
    - dialog = mBuilder.create();
    - dialog.show()

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

    amazing thanks! Greetings from Mexico

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

    Thank you for this tutorial, it really helped me out.

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

    Nicely done!

  • @p32929
    @p32929 7 ปีที่แล้ว +4

    Thank you so much for this amazing video...
    #Subscribed :)

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

      Thanks for watching and subscribing to the channel :D

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

      You're most welcome ^_^

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

    hey bro, awesome work,
    but I have a question how to dismiss like in the normal dialog video.

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

      I have done it, just make the dialog object global and dismiss it from inside the log in button handler.

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

      That's awesome :)

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

      what was your code to do that?

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

    Merci pour ce petit tuto.

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

    Thanks for the video, very usefull :)

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

      Thanks for watching :)

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

    Thanks A LOT !! You saved me with this!

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

    can i add recyclerview in dialog
    or what is the best way to put recyclerview in popup

  • @l.aguirre5550
    @l.aguirre5550 4 ปีที่แล้ว

    gracias. . como hago al final despues de presionar el boton login desaparezca el layout creado??

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

    Hello sir. i had a query. If i wanted the button on the dialog to redirect me to a different page how do i implement it? For example if i had a modify button on the dialog which takes me to a different page, how will it work?

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

      Hi, inside mLogin onClick method you add the following code:
      startActivity(new Intent(MainActivity.this, NewActivity.class));
      Note: (NewActivity.class) is the page that you want to send the user to.

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

    amazing man.... Hats off....

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

    big thank man, this really work for me

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

      That's awesome, happy coding :D

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

    Gracias, me fue de mucha ayuda.

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

    Thanks a lot.. very helpfull..

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

    Thank you very much, great tutorial!

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

    My biggest complaint with this video is that it does not show you any useful use case for the button. For example, how do you get the login button to close the dialog on success? (Showing a toast is pretty useless imo), How do I get and set the values of these editTexts? Though it's just a case of accessing their variables it would make this video complete

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

    great tutorial! thanks

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

    Good but you forgot the most important part, how to close it. Don't work with dismiss()

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

      I got it to work define AlertDialog dialog as final. "final AlertDialog dialog = mBuilder.create();" Then you can call dismiss(). Like someone answered here: stackoverflow.com/questions/49349668/how-to-dismiss-custom-alert-dialog

  • @vlle.2567
    @vlle.2567 6 ปีที่แล้ว

    very helpful! thanks!

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

    Thank you very much.

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

    hi thank you very much for this tutorial,
    can you just show us how to dismiss the dialog because i am trying with dialog.dismiss() but it doesn't work

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

    This was awesome .. Thanks a lot.

  • @YogendraSingh-jh1lz
    @YogendraSingh-jh1lz 7 ปีที่แล้ว

    Instantly Subscribed :)

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

    I have created a dialog like this , but at onClickListener method I have a variable that its value is changing and it giving me an error saying "Variable is accessed within inner class. Needs to be declared final"
    I can't declare it final because its value is changing
    what should I do please?

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

      Hi, in that case you can declare that variable on top not inside any inner method, so that you can reference that variable without declaring it as final

  • @AshishSharma-em9sk
    @AshishSharma-em9sk 7 ปีที่แล้ว +1

    I want to go to another activity click on a button on the dialog box. I am trying but not able to move it there I think because it is layout resource file. I just want to work with this dialog box work on click event. please help me.

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

      Hi, you don't have to make any changes in the layout resource file, based on the video there is a login button so let's say you want to go to another activity whenever the user taps on the button, you can do it like this:
      Inside the mLogin.setOnClickListener method replace the the toast message with the following line: startActivity(new Intent(MainActivity.this, NewActivity.class));
      Now when the user taps on the login button it will send the user to another page.
      I hope that helps :)

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

    Perfect! Thank you!

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

    hey men can you do a tutorial that combine two application in one? btw this is helpful vid goodjob

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

      Hi, thanks for watching :)
      Sorry what do you mean by "combine two application in one"?

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

      Like i create app A and the other app B is a source code is it possible to combine those 2 app in one?

  • @RankiandoNasProvas
    @RankiandoNasProvas 6 ปีที่แล้ว +2

    How do I close a dialog box after clicking on the button?

  • @saadahmed4083
    @saadahmed4083 7 ปีที่แล้ว +5

    How to add also cancel button in this custom dialog?

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

      Hi, create a button inside the dialog_login.xml file and you can place it under the login button, then declare the cancel button inside alertdialog like i did for the login button. Inside the cancel button's onClick method you can dismiss the dialog like this:
      final AlertDialog dialog = mBuilder.create();
      dialog.show();
      mCancel.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      dialog.dismiss();
      }
      });

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

      Thanks

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

      Your welcome :)

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

    awesome video!

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

    Thanks mate!

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

    Amazing video!!

  • @MuhammadAsif-py6ck
    @MuhammadAsif-py6ck 7 ปีที่แล้ว

    can you please make a tutorial on how to enable pop ups by default for web app. because my website need pop ups enable to open after login. i already make app for that website but after login it shows nothing not even pop ups notification.

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

    Hey I have a problem!
    When I click edittext the keyboard doesn't show the input doesn't work .

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

      Hi, hmm that's strange! Do you see any errors in logcat? You can email me (codingdemos@gmail.com) the source code so that i can see what is the issue

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

      Coding Demos Thanks For This Tutorial it Helped Me A lot .Anyway how can I close this dialog using a button? Coz the dismiss doesn't work !

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

      First you need to show the alertdialog and then call button setOnClickListener to make the button clickable. Inside the OnClick method is where you will dismiss the dialog like this:
      final AlertDialog dialog = mBuilder.create();
      dialog.show();
      mLogin.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      if(!mEmail.getText().toString().isEmpty() && !mPassword.getText().toString().isEmpty()){
      Toast.makeText(MainActivity.this,
      R.string.success_login_msg,
      Toast.LENGTH_SHORT).show();
      dialog.dismiss();
      }else{
      Toast.makeText(MainActivity.this,
      R.string.error_login_msg,
      Toast.LENGTH_SHORT).show();
      }
      }
      });

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

      Thanks Man ! I subscribed !!!!

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

      Your welcome and thanks for subscribing :)

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

    thank you very much , this video is usefull

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

    Can you explain How to set custom Layout on Item click Listener of Recyclerview

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

      Hi, please check out the new tutorial about Recyclerview: th-cam.com/video/RIoyRhlo5Oo/w-d-xo.html

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

    Excellent Tutorial!.. Thanks! .
    Subscribed!

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

      Your welcome, happy coding :)

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

    i want a dialog box after clicking on icon at action bar i.e add, for this how can we initialize the icon in main activity?

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

      Hi, all you have to do is follow the tutorial that i did which will teach you how to create the option menu, and then you can use this alertdialog code together to show the dialog every time you click on any items in the option menus.
      Here is the video tutorial link: th-cam.com/video/EZ-sNN7UWFU/w-d-xo.html

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

      Thank You!

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

    Good Video!, I have a question, How can I prevent that the dialog closes when I touch outside it?

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

      Hi, you can call mBuilder.setCancelable(false)

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

    Valeu amigo. Me ajudou muito. Obrigado

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

    I copied the source code but the result of the alert dialog is in full screen. How can i minimize and adjust it to center? Thanks

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

      Hi, please email me (codingdemos@gmail.com) the source code so that i can see what's the problem

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

    thanks you very much

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

    And what if we want the dialog in a fragment ?

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

    stuck with the (" else ", unexpected token) with a red line, what is the problem!
    how can i get the code?
    thank you for this helpful video :)

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

      Hi, you can access the source code at this link: github.com/codingdemos/CustomAlertDialogTutorial
      Please let me know if you need any help with the code above

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

    Hey I have created two buttons and I did exact same thing as you but my onClickListener is not working at all.

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

      Hi, do you get any error message in the logcat?

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

      @@CodingDemos I fixed it. I had to put onClickListeners after dialog.show(); not before.

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

      Awesome :)

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

    Thanks a lot.

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

    How we can save the text in to the file from edit text by click on yes

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

      You should use something called shared preferences to store the data

  • @Manikandan-qc7ei
    @Manikandan-qc7ei 4 ปีที่แล้ว

    My dialog layout widgets Id will not shown here. How to solve it?.

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

    excelent :D thank you

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

    You are a creative .... but the rest of Shi ... Possible to download us a video printing Arabic and but to the large character of paper size A4 .... you are thankful ... Please please please 🥺 🙏

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

    How to auto close the popup after button click?

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

      Ajay Sajeev declare the Alert Dialog as a Global Variable and inside the onClickListener type the name of the global Variable and put the cancel button
      // Global Variable
      AlertDialog ad;
      ........
      onClick{
      ad.cancel
      }
      You surely need to look up at Stack overflow....Even I checked it.

  • @md.shafiqulislam15
    @md.shafiqulislam15 6 ปีที่แล้ว

    super tutorial

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

      I'm happy to hear that :)

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

    how to disable dialog when click the button...

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

    Great tutorial! Thank you a lot!

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

    hi mister plz when i click on button in dialog the email and pasw edit texts are not appeared. how solve it?

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

      Hi, is there any error message in the logcat?

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

      @@CodingDemos i not have error in logcate the app it run but when i clicked button not respons

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

    how can i open another fragment when is succes ?

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

    Thanks a lot;

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

    Any text inputed into the Editext shows up as null.
    AlertDialog.Builder mBuilder = new AlertDialog.Builder(HomePage.this);
    View mView = LayoutInflater.from(HomePage.this).inflate(R.layout.dialog_new_post, null); //does not work when u try to do it the way u have it in your video
    EditText etNewPostDialog = (EditText) mView.findViewById(R.id.etNewPostDialog);
    Button btnCreatePostDialog = (Button) mView.findViewById(R.id.btnNewPostDialog);
    final String newPostDialog = etNewPostDialog.getText().toString().trim();
    final String username = SharedPrefManager.getInstance(this).getUsername();
    // final String post = etNewPostDialog.getText().toString();
    btnCreatePostDialog.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    //sendUserPost(username);
    Toast.makeText(HomePage.this, newPostDialog, Toast.LENGTH_SHORT).show();
    }
    });
    mBuilder.setView(mView);
    AlertDialog dialog = mBuilder.create();
    dialog.show();
    }
    So far every way I have tried it has returned null. Also side question how would you close the dialog. Thanks for the help thus far tho

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

      Hi, do you get any error in the logcat when you try to insert a value in the edittext?
      and may i know why this line doesn't work (View mView = getLayoutInflater().inflate(R.layout.dialog_login, null);) do you get any errors?
      You can email me (codingdemos@gmail.com) your project code and i'll do my best to help you :)

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

      Appreciate the response, I figured it out, I went about it a bit differently then your video, but still got the correct end result. This is what I did to fix it. Thanks again for the video. Actually helped a lot.
      public void displayDialog(){
      LayoutInflater layoutInflater = LayoutInflater.from(this);
      final View inflator = layoutInflater.inflate(R.layout.dialog_new_post, null);
      AlertDialog.Builder alert = new AlertDialog.Builder(this);
      alert.setTitle("Title");
      final EditText etNewDialogPost = (EditText) inflator.findViewById(R.id.etNewPostDialog);
      alert.setPositiveButton("ok", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialogInterface, int i) {
      final String etNewPostDialog = etNewDialogPost.getText().toString().trim();
      //do something
      }
      });
      alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialogInterface, int i) {
      dialogInterface.cancel();
      }
      });
      alert.show();
      }

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

      That's great :)

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

    What font do you use there?

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

      Hi, may I know which part are you referring to?

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

      What? I asked - "What font do you use in Android Studio?"

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

      Oh i'm not using any special font, that is the default font in Android Studio. For the black theme I'm using Dracula :)

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

    Thanks alot!

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

    thank you bro

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

    thanks a lot

  • @md.rajibulislamshopnil2260
    @md.rajibulislamshopnil2260 7 ปีที่แล้ว +1

    *_Thanks for this video_*

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

      Your welcome, happy coding :)

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

    how to i intend to new activity by click on the item ?

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

      Hi Yusri, for example if you want to start a new activity when clicking on a button you can do it like this:
      Button button = (Button) findViewById(R.id.button1);
      button.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
      Intent mIntent = new Intent(MainActivity.this, SecondActivity.class)
      startActivity(mIntent);
      }
      });
      Happy coding :)

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

      based on your coding can i go to another page after i click the item from the spinner . You just show toast message .

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

      Yes you can...Here is how you can do it:
      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();
      }
      }
      });
      For more info you can refer to this tutorial: th-cam.com/video/nlqtyfshUkc/w-d-xo.html

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

      still cant , it work for first item , then if i add second page for second item , first item will go to second item page

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

      yeah that will happen because we only used 1 intent which to go from MainActivity.java to SecondActivity.java and that will apply to all item(s) inside the spinner. Now it seems that in your case you have multiple items inside your spinner which will direct the user to different screens, to handle this type of case you will need to check like this:
      if(mSpinner.getSelectedItem().toString().equalsIgnoreCase("Burger King")) {
      startActivity(new Intent(MainActivity.this, BurgerKingActivity.class));
      }else
      if(mSpinner.getSelectedItem().toString().equalsIgnoreCase("Dominos Pizza")){
      startActivity(new Intent(MainActivity.this, PizzaActivity.class));
      }
      If you need more help you can email me your code (codingdemos@gmail.com) and i'll do my best to help you out :)

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

    thanks
    Now I know how i can do that

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

      Awesome, happy coding :)

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

    Thank you

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

    Nice, but how I close this window after the login without click in back button?

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

      Hi, inside the login button onClickListener you add dialog.dismiss

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

      @@CodingDemos , tnks again man, I found here... Now I have some other problem, and I don't know if you can help me, I catch my APK from app build folder and pass for some peoples, in some cel the works fine but in some don't, show message " crashes continuously " or something like this... Do you ever see it?

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

      That's great :)
      Regarding the crash issue, I can't really help you unless you tell me the exact error. You can see that from the Logcat in Android Studio. If you don't have access to other cell where the crash issue happened, then you may want to use Firebase crashlytics. You add it in your app and then share the app with other cell where the crash happened, and then you will be able to see the crash report through Firebase crashlytics.

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

      @@CodingDemos tks again.

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

      You're welcome :)