Advertisement
kusha45

Dialog box

Dec 22nd, 2011
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. //Click event of button
  2. btnDeleteIssue.setOnClickListener(new OnClickListener() {
  3.            
  4.     public void onClick(View v) {
  5.         ReasonDialog(AddDisplayIssue.this);                    
  6.         System.out.println("The reason is  :"+reason);
  7.     }
  8. });
  9. //Function
  10.  
  11. public void ReasonDialog(final Context ctx) {
  12.         final Dialog dialog = new Dialog(ctx);
  13.         dialog.setContentView(R.layout.dialogsearch);
  14.         dialog.setTitle("     Enter The Reason to Delete ");
  15.         dialog.setCancelable(true);
  16.         final boolean temp = false;
  17.         final EditText Text = (EditText) dialog.findViewById(R.id.EdText);
  18.        
  19.         Button buttonOK = (Button) dialog.findViewById(R.id.btnOK);
  20.         buttonOK.setOnClickListener(new OnClickListener() {
  21.            
  22.             public void onClick(View v) {
  23.                 reason = Text.getText().toString();
  24.                 System.out.println("Reason in dialog :"+reason);
  25.                 dialog.cancel();
  26.             }
  27.         });
  28.        
  29.         Button buttonCancel = (Button) dialog.findViewById(R.id.btnCancel);
  30.         buttonCancel.setOnClickListener(new OnClickListener() {
  31.            
  32.             public void onClick(View v) {
  33.                 dialog.cancel();
  34.             }
  35.         });
  36.        
  37.         dialog.show();
  38.     }
  39.  
  40. OUTPUT:
  41. The reason is  : null
  42. Reason in dialog : Testing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement