title: Add dropdownlist spinner to alert dialogue Android Studio
body: <p>I'm trying to add a search form with a edittext and dropdownlist spinner to alert dialogue. I have managed to get the edit text to display, but I cannot figure out how to add the spinner. I'm new to android so any help would be appreciated.</p>
  
  <pre><code>private void LoadSearchDialogue()
      {
          android.app.AlertDialog.Builder alertDialogSearchForm = new android.app.AlertDialog.Builder(this);
          alertDialogSearchForm.setTitle("Search Form");
          alertDialogSearchForm.setMessage("Please complete form");
          final EditText textViewInputUsername = new EditText(this);
          final Spinner spinnerSearchOptions = new Spinner(this);
  
          Spinner dropdownSearchOptions = (Spinner)findViewById(R.id.spinnerSearchOptions);
          String[] items = new String[]{"Customer", "Employee","Date" };
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;&gt;(this, android.R.layout.simple_spinner_dropdown_item, items);
          dropdownSearchOptions.setAdapter(adapter);
  
          mQuery              = (EditText) findViewById(R.id.query);
          mSearchOption       = (Spinner) findViewById(R.id.spinnerSearchOptions);
  
  
  
  
          alertDialogSearchForm.setView(textViewInputUsername);
          alertDialogSearchForm.setPositiveButton("Continue",
  
                  new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          //Do nothing here, overriding alert dialogue button
                      }
                  });
          final android.app.AlertDialog dialog = alertDialogSearchForm.create();
          dialog.show();
          dialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener()
          {
              @Override
              public void onClick(View v)
              {
                  Boolean closeAlertDialogueOnValidInput = false;
                  //Check if query is entered,
                  String mQueryString = textViewInputUsername.getText().toString().trim();
                  if(mQueryString.length()&lt;=0)
                  {
                      Toast.makeText(SearchActivity.this, "Please enter query", Toast.LENGTH_SHORT).show();
                  }
                  else
                  {
                      String q            = mQueryString.toString();
                      String o            = mSearchOption.getSelectedItem().toString();
                      SearchResults(q, o);
                  }
  
                  if(closeAlertDialogueOnValidInput)
                      dialog.dismiss();
  
              }
          });
  
  
  
      }
  </code></pre>