Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android popup dialog

Tags:

android

I'm trying to find a way to create a popup screen for some user input which includes radio button, editText, button. I don't want to start a new activity. what would be a good option? AlertDialog? Spinner?Popup menu? Thanks

like image 756
Dennis Hui Avatar asked Jul 16 '26 10:07

Dennis Hui


1 Answers

AlertDialog would be fine for this. You can declare a layout.xml file with all of the components you'll need and then inflate it and set it as the content of your dialog.

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.yourLayoutId, (ViewGroup) findViewById(R.id.yourLayoutRoot));
    AlertDialog.Builder builder = new AlertDialog.Builder(this)
    .setView(layout);
    AlertDialog alertDialog = builder.create();
    alertDialog.show();
like image 67
FoamyGuy Avatar answered Jul 17 '26 23:07

FoamyGuy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!