title: Null Exception In Android EditText while deleting the last character
body: <p>I'm new to Android programming.
  My following program does a simple Farenheit to Celsius conversion.
  If you enter values in a Farenheit EditText it will convert it into Celsius immediately.
   And Vice versa.</p>
  
  <p>I'm getting the following errors:</p>
  
  <p>When I Keep entering values in Farenheit text box there is no issue. When I delete the value also, It is deleting fine till the last character. 
  If I press backspace(in emulator) to delete the lastcharacter it stops running.
  I'm getting the following error when I run my code.</p>
  
  <p>2) Even though the focus was set on Celsius EditText the emulator always shows the Fahreinheit as focussed when it is initiated</p>
  
  <p>3) The Changes I make in Celsius edit text are not reflected in Fahrenheit.</p>
  
  <p>(please don't think I posted in forum without debugging, I have tried for more than 3 hours before posting here so that I can keep this forum clean )</p>
  
  <p>07-29 01:59:21.189: E/AndroidRuntime(1390): java.lang.NumberFormatException: Invalid float: ""</p>
  
  <p>Following is my MainActivity.Java</p>
  
  <pre><code>  public class MainActivity extends Activity {
       private EditText celsiusText;
       private EditText farenheitText;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          celsiusText = (EditText) findViewById(R.id.editText1);
          farenheitText = (EditText) findViewById(R.id.editText2);
          celsiusText.requestFocus();
          celsiusText.setOnFocusChangeListener((OnFocusChangeListener) this);
          farenheitText.setOnFocusChangeListener((OnFocusChangeListener) this);
      }
         public void onFocusChange(View v, boolean hasFocus)
  
          {
  
             TextWatcher watcher1 = new TextWatcher(){
              public void afterTextChanged(Editable s) {
  
                 }
  
                 public void beforeTextChanged(CharSequence s, int start, 
                   int count, int after) {
                 }
              public void onTextChanged(CharSequence S,int start,int before, int count){
                  float inputValue;
                  if (!S.toString().equals(""))
                  {
                      inputValue = Float.parseFloat(S.toString());
                               ((EditText)findViewById(R.id.editText1)).setText(String
                                      .valueOf(convertFahrenheitToCelsius(inputValue)));
  
                  }
                  else
                  {
                       ((EditText)findViewById(R.id.editText1)).setText("");
                      return;
                  }
                          }
             };
  
  
  
             TextWatcher watcher2 = new TextWatcher()
             {
                          public void afterTextChanged(Editable s) {
  
                     }
  
                     public void beforeTextChanged(CharSequence s, int start, 
                       int count, int after) {
                     }
                  public void onTextChanged(CharSequence S,int start,int before, int count){
                      float inputValue;
                      if (!S.toString().equals(""))
                      {
                          inputValue = Float.parseFloat(S.toString());
                       ((EditText)findViewById(R.id.editText2)).setText(String
                                  .valueOf(convertCelsiusToFahrenheit(inputValue)));
  
                      }
                      else
                      {
                          ((EditText)findViewById(R.id.editText2)).setText("");
                          return;
                      }
                              }
                  };
  
                  if((v == findViewById(R.id.editText2)) &amp;&amp;  (hasFocus==true)) 
                  {
                  farenheitText.addTextChangedListener(watcher1);
                  }
                  else if ((v == findViewById(R.id.editText1)) &amp;&amp;  (hasFocus==true)) 
                  {
                      ((EditText)findViewById(R.id.editText1)).setText("");
                  celsiusText.addTextChangedListener(watcher2);
                  }
          }
  
  
  
  
  
  //Converts to celsius
        private float convertFahrenheitToCelsius(float fahrenheit) {
          return ((fahrenheit - 32) * 5 / 9);
        }
  
        // Converts to fahrenheit
        private float convertCelsiusToFahrenheit(float celsius) {
          return ((celsius * 9) / 5) + 32;
        }
  
  }
  </code></pre>
  
  <p>My Activity_main.xml is </p>
  
  <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:paddingLeft="16dp"
      android:paddingRight="16dp" &gt;
  
      &lt;EditText
          android:id="@+id/editText1"
          android:layout_width="128dp"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="62dp"
          android:ems="10"
          android:inputType="numberSigned" &gt;
  
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;EditText
          android:id="@+id/editText2"
          android:layout_width="128dp"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/editText1"
          android:layout_alignBottom="@+id/editText1"
          android:layout_alignParentRight="true"
          android:ems="10"
          android:inputType="numberSigned" /&gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/editText1"
          android:layout_below="@+id/editText1"
          android:layout_marginTop="18dp"
          android:text="@string/celsius"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/textView1"
          android:layout_alignBottom="@+id/textView1"
          android:layout_alignRight="@+id/editText2"
          android:text="@string/fahrenheit"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>As you can see my next step would be editing text box both the sides, Any help of how to converting this code to celsius (with setfocus so that it won't throw error) will also be appreciated.</p>