vijay
11/5/2014 - 10:29 AM

AlertDialog

AlertDialog

public void PromptAlertbox()  
{ 
    AlertDialog.Builder alert = new AlertDialog.Builder(this);  
    alert.setTitle("Title"); alert.setMessage("Message");  
    
    // Set an EditText view to get user input  
      final EditText input = new EditText(this);  
      alert.setView(input);  
      alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() 
          {  
            public void onClick(DialogInterface dialog, int whichButton)  {  
                  prompt_other_value = input.getText().toString();  
                  ed_selectsubject.setText(input.getText().toString());  
                    
                    // Do something with value!  
                    
          } });  
  
        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener()  
              { 
                  public void onClick(DialogInterface dialog, int whichButton)  
                      { 
                            // Canceled.  
                      } 
        } 
            ); 
  alert.show(); }
 private void AlertDialogTest() {
        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
        // ...Irrelevant code for customizing the buttons and title
        LayoutInflater inflater = this.getLayoutInflater();
        View dialogView = inflater.inflate(R.layout.alert_label_editor, null);
        dialogBuilder.setView(dialogView);

        EditText editText = (EditText) dialogView.findViewById(R.id.label_field);
        editText.setText("test label");
        AlertDialog alertDialog = dialogBuilder.create();
        alertDialog.show();
    }