title: android check if EditText is empty and then avoid dialog from canceling
body: <p>Hey in my app for android, I am trying to make a dialog, with a EditText. My problem with my code is, if my EditTex is empty the app will not work. Therefore I am trying to check if the EditText is empty and prevent the dialog from canceling if the EditText is empty.
  Thanks in advance</p>
  
  <p>Here is the code:</p>
  
  <pre><code>private void AdPoint() {        
   final AlertDialog.Builder alert = new AlertDialog.Builder(this);
       LinearLayout linearlayout= new LinearLayout(this);
       linearlayout.setOrientation(1);         
          final EditText point_field = new EditText(this);
          final String point_field_string = point_field.getText().toString();
          point_field.setImeOptions(InputType.TYPE_CLASS_NUMBER);
          point_field.setRawInputType(Configuration.KEYBOARD_12KEY);
  
          linearlayout.addView(point_field);
  
          alert.setView(linearlayout);
          alert.setCancelable(false);
          alert.setTitle(playername1string);
          alert.setMessage(R.string.how_many_point);
  
          point_field.setHint("10");
          playername1.setText(playername1string);
  
  
          alert.setPositiveButton(R.string.plus, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
  
  
                  if (point_field_string.matches("")) {                   
                      //My code, if the EditText is not emty                      
                      return;
                  }else {
                  point_field.setText("0");
  
                  }
  
  
  
                          }
  
          });
          alert.show();  
  }   
  </code></pre>