title: validate editText on buttonclick event
body: <p>I am new in android programming and still learning. for practice i started to create a very simple and basic app which calculate age on button click which take birth year as an input.
  i manage to get it working and want to do some validation on it. like i have done validating that the value we provide should not be more than current year and i successfully done that.</p>
  
  <p>Now my problem is that i also want to put validation that if no input is been made and button is pressed then it should alert the user by Toast. So far i have tried doing but every time i press button without anything in editText the app just crash.</p>
  
  <p>here's my code.</p>
  
  <pre><code>        calcAge.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
  
  
  
               if(dob &gt; year){
  
                  Toast.makeText(getApplicationContext(), "Provide valid Input", Toast.LENGTH_SHORT).show();
              }
  
               else if(String.valueOf(dob) == null){
  
                   Toast.makeText(getApplicationContext(), "Please Provide Some Input", Toast.LENGTH_SHORT).show();
               }
  
              else{
  
  
                  dob = Integer.parseInt(String.valueOf(inAge.getText()));
                  currentYear.setText("Your Curret Year is :- " + year);
                  yourYear.setText("Your Birth Year is :- "+ dob);
  
              int a = year-dob;
  
              finalAns.setText("Your Age is :- " + a);
  
              inAge.setText("");
  
              }
  
  
  
          }
      });
  </code></pre>
  
  <p>above code is of button click. Please provide with some solution</p>
  
  <p>I have also tried putting editText1.getText().toString.trim().lenght()==0 in if condition but that also didn't worked and app just crashes.</p>