title: How to allow user to enter data in the edit text if only previous edittext are filled
body: <p>I have eight <code>EditText</code>s in my code. I need to allow the user to enter the data in an <code>EditText</code> only if the previous <code>EditText</code> is filled, otherwise I have to prompt that one of the previous <code>EditText</code>s is blank. How do I achieve this?</p>
  
  <pre><code>package com.sabari.results;
  
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  public class Calculator extends AppCompatActivity {
  
      TextView tv1;
      TextView tv2;
      TextView tv3;
      TextView tv4;
      TextView tv5;
      TextView tv6;
      TextView tv7;
      TextView tv8;
      TextView tv10;
      EditText et1;
      EditText et2;
      EditText et3;
      EditText et4;
      EditText et5;
      EditText et6;
      EditText et7;
      EditText et8;
      Button b1;
      Button b2;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setTitle("CGPA Calculator");
          setContentView(R.layout.calculator);
  
          tv1 = (TextView) findViewById(R.id.textView);
          tv2 = (TextView) findViewById(R.id.textView2);
          tv3 = (TextView) findViewById(R.id.textView3);
          tv4 = (TextView) findViewById(R.id.textView4);
          tv5 = (TextView) findViewById(R.id.textView5);
          tv6 = (TextView) findViewById(R.id.textView6);
          tv7 = (TextView) findViewById(R.id.textView7);
          tv8 = (TextView) findViewById(R.id.textView8);
  
  
          b1 = (Button)findViewById(R.id.button);
          b2 = (Button)findViewById(R.id.button2);
  
  
          b1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  et1 = (EditText) findViewById(R.id.editText);
                  et2 = (EditText) findViewById(R.id.editText2);
                  et3 = (EditText) findViewById(R.id.editText3);
                  et4 = (EditText) findViewById(R.id.editText4);
                  et5 = (EditText) findViewById(R.id.editText5);
                  et6 = (EditText) findViewById(R.id.editText6);
                  et7 = (EditText) findViewById(R.id.editText7);
                  et8 = (EditText) findViewById(R.id.editText8);
  
  
  
  
  
  
                  tv10 = (TextView) findViewById(R.id.textView10);
                  int n=1;
  
  
                  double no1,no2,no3,no4,no5,no6,no7,no8;
                  double g1=0,g2=0,g3=0,g4=0,g5=0,g6=0,g7=0,g8=0;
  
                  try {
                      no1 = Double.parseDouble(et1.getText().toString());
                      if(no1&gt;=5&amp;&amp;no1&lt;=10)
                      {
                          g1=no1;
                          n=1;
                      }
                      else{
                          Toast.makeText(Calculator.this,"Please enter a valid GPA",Toast.LENGTH_LONG);
                      }
                  }catch (NumberFormatException e){
                      e.printStackTrace();
  
                  }
                  try{
                      no2 = Double.parseDouble(et2.getText().toString());
                      if(no2&gt;=5&amp;&amp;no2&lt;=10)
                      {
                          g2=no2;
                          n=2;
                      }
                      else{
                          Toast.makeText(Calculator.this,"Please enter a valid GPA",Toast.LENGTH_LONG);
                      }
  
                  }
                  catch (NumberFormatException e){
                        e.printStackTrace();
                  }
                  try {
                      no3 = Double.parseDouble(et3.getText().toString());
                      if(no3&gt;=5&amp;&amp;no3&lt;=10)
                      {
                          g3=no3;
                          n=3;
                      }
                      else{
                          Toast.makeText(Calculator.this,"Please enter a valid GPA",Toast.LENGTH_LONG);
                      }
  
                  }catch (NumberFormatException e){
                      e.printStackTrace();
                  }
                  try {
                      no4 = Double.parseDouble(et4.getText().toString());
                      if(no4&gt;=5&amp;&amp;no4&lt;=10)
                      {
                          g4=no4;
                          n=4;
                      }
                      else{
                          Toast.makeText(Calculator.this,"Please enter a valid GPA",Toast.LENGTH_LONG);
                      }
  
                  }catch (NumberFormatException e)
                  {
                      e.printStackTrace();
                  }
                  try{
                      no5 = Double.parseDouble(et5.getText().toString());
                      if(no5&gt;=5&amp;&amp;no5&lt;=10)
                      {
                          g5=no5;
                          n=5;
                      }
                      else{
                          Toast.makeText(Calculator.this,"Please enter a valid GPA",Toast.LENGTH_LONG);
                      }
                  }catch (NumberFormatException e){
                      e.printStackTrace();
                  }
                  try{
                      no6 = Double.parseDouble(et6.getText().toString());
                      if(no6&gt;=5&amp;&amp;no6&lt;=10)
                      {
                          g6=no6;
                          n=6;
                      }
                      else{
                          Toast.makeText(Calculator.this,"Please enter a valid GPA",Toast.LENGTH_LONG);
                      }
                  }catch (NumberFormatException e){
                      e.printStackTrace();
                  }
                  try {
                      no7 = Double.parseDouble(et7.getText().toString());
                      if(no7&gt;=5&amp;&amp;no7&lt;=10)
                      {
                          g7=no7;
                          n=7;
                      }
                      else{
                          Toast.makeText(Calculator.this,"Please enter a valid GPA",Toast.LENGTH_LONG);
                      }
                  }catch (NumberFormatException e){
                      e.printStackTrace();
                  }try {
                      no8 = Double.parseDouble(et8.getText().toString());
                      if(no8&gt;=5&amp;&amp;no8&lt;=10)
                      {
                          g8=no8;
                          n=8;
                      }
                      else{
                          Toast.makeText(Calculator.this,"Please enter a valid GPA",Toast.LENGTH_LONG);
                      }
                  }catch (NumberFormatException e){
                      e.printStackTrace();
                  }
  
  
  
  
  
                  double res = 0;
  
  
  
                  if(et1.getText().length()!=0||
                          (et1.getText().length()!=0&amp;&amp;et2.getText().length()!=0)||
                          (et1.getText().length()!=0&amp;&amp;et2.getText().length()!=0&amp;&amp;et3.getText().length()!=0)||
                          (et1.getText().length()!=0&amp;&amp;et2.getText().length()!=0&amp;&amp;et3.getText().length()!=0&amp;&amp;et4.getText().length()!=0)||
                          (et1.getText().length()!=0&amp;&amp;et2.getText().length()!=0&amp;&amp;et3.getText().length()!=0&amp;&amp;et4.getText().length()!=0&amp;&amp;et5.getText().length()!=0)||
                          (et1.getText().length()!=0&amp;&amp;et2.getText().length()!=0&amp;&amp;et3.getText().length()!=0&amp;&amp;et4.getText().length()!=0&amp;&amp;et5.getText().length()!=0&amp;&amp;et6.getText().length()!=0)||
                          (et1.getText().length()!=0&amp;&amp;et2.getText().length()!=0&amp;&amp;et3.getText().length()!=0&amp;&amp;et4.getText().length()!=0&amp;&amp;et5.getText().length()!=0&amp;&amp;et6.getText().length()!=0&amp;&amp;et7.getText().length()!=0)||
                          (et1.getText().length()!=0&amp;&amp;et2.getText().length()!=0&amp;&amp;et3.getText().length()!=0&amp;&amp;et4.getText().length()!=0&amp;&amp;et5.getText().length()!=0&amp;&amp;et6.getText().length()!=0&amp;&amp;et7.getText().length()!=0&amp;&amp;et8.getText().length()!=0)) {
  
  
                      res = (g1+g2+g3+g4+g5+g6+g7+g8) / n;
                      tv10.setText("Your CGPA is : " + res);
                      Toast.makeText(Calculator.this, "Your CGPA is : " + res, Toast.LENGTH_LONG).show();
                  }
                  else{
                      Toast.makeText(Calculator.this,"Please enter the required fields` ",Toast.LENGTH_LONG).show();
                  }
  
              }
  
          });
          b2.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  et2.setText("");
                  et3.setText("");
                  et4.setText("");
                  et5.setText("");
                  et6.setText("");
                  et7.setText("");
                  et8.setText("");
                  tv10.setText("Your CGPA is : ");
                  et1.setText("");
  
              }
          });
  
  
      }
  
  
  }
  </code></pre>