Hey all
 
I am trying to make an app what needs to take two number input from the user, and then preform some math to them (In the example code I have just made them + each other).
 
Here is the code, it seems to work if you fill the bottom one first, and then the top one, but if you delete the text in the bottom one the app crashes. Hope you can help.
 
Thanks in advance.

edit: when it crashed for me it was on line 49, due to invalid float: ""

acivity_mail.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="numberDecimal"
        android:ems="10"
        android:id="@+id/num1EditText"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="61dp" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="numberDecimal"
        android:ems="10"
        android:id="@+id/num2EditText"
        android:layout_marginTop="68dp"
        android:layout_below="@+id/num1EditText"
        android:layout_alignLeft="@+id/num1EditText"
        android:layout_alignStart="@+id/num1EditText" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="+"
        android:id="@+id/textView"
        android:layout_below="@+id/num1EditText"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="28dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="="
        android:id="@+id/textView2"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Result here"
        android:id="@+id/resultTextView"
        android:layout_below="@+id/textView2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="46dp" />

</RelativeLayout>


MailActivity.java

package com.example.nicolai.myapplication;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
import android.text.TextWatcher;
import java.lang.Float;



public class MainActivity extends ActionBarActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final TextView num1TextView = (TextView) findViewById(R.id.num1EditText);
        final TextView num2TextView = (TextView) findViewById(R.id.num2EditText);

        final TextView resultTextView = (TextView) findViewById(R.id.resultTextView);

        num1TextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            // here im trying to make some sort of verification that num1TextView is not empty
                if(num1TextView.getText().toString() != ""){
                    num2TextView.addTextChangedListener(new TextWatcher() {
                        @Override
                        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                        }

                        @Override
                        public void onTextChanged(CharSequence s, int start, int before, int count) {
                            // here im trying to make some sort of verification that num2TextView is not empty
                            if (num2TextView.getText().toString() != ""){

                                float num1 = Float.parseFloat(num1TextView.getText().toString());
                                float num2 = Float.parseFloat(num2TextView.getText().toString());
                                float result  = num1 + num2;



                                resultTextView.setText(result+"");

                            }
                        }

                        @Override
                        public void afterTextChanged(Editable s) {

                        }
                    });
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });



    }

}