Showing posts with label android alterdialog input. Show all posts
Showing posts with label android alterdialog input. Show all posts

Oct 23, 2014

Simple android input popup


We using intent for popup window.

  1. intent=new Intent(getApplicationContext(),yourtext.class);
  2. startActivityForResult(intent,text);

And need a onActivityResult method and manifest setting!!

But we making simple popup using AlterDialog!!

  1.             AlertDialog.Builder alert = new AlertDialog.Builder(this);
  2.             alert.setTitle("Input your name");
  3.             alert.setMessage("Plz, input yourname");
  4.            
  5.             final EditText name = new EditText(this);
  6.             alert.setView(name);
  7.             alert.setPositiveButton("ok", new DialogInterface.OnClickListener() {
  8.                 public void onClick(DialogInterface dialog, int whichButton) {
  9.                     String username = name.getText().toString();
  10.                    
  11.                 }
  12.             });
  13.             alert.setNegativeButton("no",new DialogInterface.OnClickListener() {
  14.                         public void onClick(DialogInterface dialog, int whichButton) {
  15.                    
  16.                         }
  17.                     });
  18.            
  19.             alert.show();

See line 7~8!! adding EditText from normally alterdialog.

If we click to 'ok'button, we using edittext's text.

<Run>

This is simply popup input window!!