3

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

Dennis Hui
  • 215
  • 3
  • 10
  • An alert dialog should be able to do what you want. Have you looked at AlertDialog API: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.html – slayton Sep 07 '11 at 21:11

1 Answers1

7

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();
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • On PopUp's layout button: popupButton1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); – Bay Oct 06 '19 at 07:25