My android application crashes when I set a class instance
<p>I'm quite new in android programming. I am developping an application which opens well and works almost the way I want. But I have a problem and I don't have a clue about the way to solve it. This is the problem: I am filling in an EditText with a value and in my java code this value will initialize an object that I have created. But this never happens because any try to initialize the object makes my application crash. 
The editText in which I input the value to initialize the object is the one called spotText.
Can anybody help?
this is the XML code:</p>

<pre><code>&lt;LinearLayout 
    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:background="#000000"
    android:orientation="vertical"
    tools:context=".MainActivity" &gt;

&lt;ScrollView    
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"&gt;

&lt;HorizontalScrollView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"&gt;

&lt;TableLayout
    android:id="@+id/TheTable"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="0,1,2,3,4,5,6,7,8,9,10,11,12" &gt;        

 &lt;TableRow
     android:id="@+id/tbRow1"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content" &gt;

  &lt;TextView
    android:id="@+id/spot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingRight="10dp"
    android:text="@string/spot"
    android:textSize="10sp"
    android:gravity="center"
    android:textColor="@color/white" /&gt;

  &lt;TextView
        android:id="@+id/div"               
        android:text="@string/div"
        android:gravity="center"
        android:textColor="@color/white"
        android:textSize="10sp" /&gt;      

    &lt;TextView
        android:id="@+id/rate"
        android:text="@string/Rate"
        android:gravity="center"
        android:textColor="@color/white"
        android:textSize="10sp" /&gt;

    &lt;CheckBox 
        android:id="@+id/smile"
        android:text="@string/UseSmile"             
        android:textColor="@color/white"
        android:textSize="10sp"/&gt;

    &lt;TextView
        android:id="@+id/ATM"
        android:text="@string/ATM"
        android:gravity="center"
        android:textColor="@color/white"
        android:textSize="10sp" /&gt;
&lt;/TableRow&gt;

&lt;TableRow
    android:id="@+id/tbRow2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" &gt;

    &lt;EditText
        android:id="@+id/spotText"
        android:hint="@string/Spot"
        android:gravity="center"      
        android:inputType="numberSigned"
        android:textColor="@color/white"
        android:textSize="10sp" /&gt;

    &lt;EditText
        android:id="@+id/divRate"
        android:hint="@string/divRate"
        android:gravity="center"    
        android:inputType="numberDecimal"
        android:textColor="@color/white"
        android:textSize="10sp" /&gt;

    &lt;EditText
        android:id="@+id/IR"
        android:hint="@string/IRate"
        android:gravity="center"    
        android:inputType="numberDecimal"
        android:textColor="@color/white"
        android:textSize="10sp" /&gt;
    &lt;EditText
        android:id="@+id/ATMVOL"
        android:hint="@string/ATM"
        android:layout_column="4"
        android:gravity="center"    
        android:inputType="numberDecimal"
        android:textColor="@color/white"
        android:textSize="10sp" /&gt;

&lt;/TableRow&gt;        

            &lt;TableRow
                android:id="@+id/tbRow3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" &gt;

                &lt;TextView
                    android:id="@+id/product"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/product"
                    android:gravity="center"
                    android:textSize="10sp"
                    android:textColor="@color/white" /&gt;


                &lt;TextView
                    android:id="@+id/strike"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/strike"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/maturity"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/maturity"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/vol"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:text="@string/volatility"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/Qty"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:text="@string/Quantity"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/price"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="15dp"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:text="@string/price"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/delta"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/delta"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/gamma"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/gamma"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/theta"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/theta"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/vega"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/vega"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/vanna"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/vanna"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:textColor="@color/white" /&gt;

                &lt;TextView
                    android:id="@+id/vomma"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingRight="10dp"
                    android:text="@string/vomma"
                    android:textSize="10sp"
                    android:gravity="center"
                    android:textColor="@color/white" /&gt;
            &lt;/TableRow&gt;
            &lt;TableRow
                android:id="@+id/tbRow4" &gt;
                &lt;Spinner 
                    android:id="@+id/spin1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:dropDownSelector="@string/Product"
                    android:prompt="@string/Product"
                    android:entries="@array/Array"
                    android:background="@color/SpinColor"
                    android:textSize="10sp"/&gt;
                &lt;EditText
                    android:id="@+id/K1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:hint="K"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;EditText
                    android:id="@+id/T1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:hint="T"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;EditText
                    android:id="@+id/Vol1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:hint="Vol"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;EditText
                    android:id="@+id/Qty1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:hint="Qty"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;TextView
                    android:id="@+id/Px1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;           
                &lt;TextView
                    android:id="@+id/delta1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;TextView
                    android:id="@+id/gamma1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;TextView
                    android:id="@+id/theta1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;TextView
                    android:id="@+id/vega1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;TextView
                    android:id="@+id/vanna1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
                &lt;TextView
                    android:id="@+id/vomma1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="10sp"/&gt;
            &lt;/TableRow&gt;

            &lt;TableRow
                android:id="@+id/tbRow9"&gt;                
                 &lt;Button 
                    android:id="@+id/delBtn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="10sp"
                    android:text="@string/delete"/&gt;
                &lt;Button 
                    android:id="@+id/addBtn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="10sp"
                    android:text="@string/Add"/&gt;

            &lt;/TableRow&gt;
        &lt;/TableLayout&gt;

   &lt;/HorizontalScrollView&gt;
&lt;/ScrollView&gt;            
</code></pre>

<p></p>

<p>Here is the MainActivity class code</p>

<pre><code>    package com.example.lilpricer;

    import android.app.Activity;
    import android.os.Bundle;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.view.Menu;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.CheckBox;
    import android.widget.CompoundButton;
    import android.widget.CompoundButton.OnCheckedChangeListener;
    import android.widget.EditText;
    import android.widget.Spinner;
    import android.widget.TableRow;
    import android.widget.TextView;

    public class MainActivity extends Activity {

int nbRow = 1;

TableRow tb1 = null; TableRow tb2 = null; TableRow tb3 = null; TableRow tb4 = null;
TableRow tb5 = null; TableRow tb6 = null; TableRow tb7 = null; TableRow tb8 = null;
TableRow tb9 = null; 
TextView tvVol = null; TextView tvSpot;
EditText etSpot = null; EditText etDiv = null; EditText etIR = null; EditText etVol = null;
EditText etK1= null; EditText etK2= null; EditText etK3 = null; EditText etK4= null;
EditText etMat1= null; EditText etMat2= null; EditText etMat3 = null; EditText etMat4= null;
EditText etVol1= null; EditText etVol2= null; EditText etVol3 = null; EditText etVol4= null;
EditText etQty1= null; EditText etQty2= null; EditText etQty3 = null; EditText etQty4= null;
Spinner spin1 = null; Spinner spin2 = null; Spinner spin3 = null; Spinner spin4 = null;
Button Del = null; Button Add = null; Button Price = null;
CheckBox cbSmile = null;
Stock S=null; 
Future Fut1 = null; Future Fut2 = null; Future Fut3 = null; Future Fut4 = null;
Option Opt1 = null; Option Opt2 = null; Option Opt3 = null; Option Opt4 = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    setWidgetRef();


    tb5.setVisibility(View.INVISIBLE); tb6.setVisibility(View.INVISIBLE); tb7.setVisibility(View.INVISIBLE); 
    tvVol.setVisibility(View.INVISIBLE); etVol.setVisibility(View.INVISIBLE);       


    etSpot.addTextChangedListener(new TextWatcher() {
        double TheSpot= 0;          
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            TheSpot=Double.parseDouble(etSpot.getText().toString());                
            S.SetStock(TheSpot);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}



private void setWidgetRef()
    {
        tb1 = (TableRow) findViewById(R.id.tbRow1); tb2 = (TableRow) findViewById(R.id.tbRow2);
        tb3 = (TableRow) findViewById(R.id.tbRow3); tb4 = (TableRow) findViewById(R.id.tbRow4);
        tb5 = (TableRow) findViewById(R.id.tbRow5); tb6 = (TableRow) findViewById(R.id.tbRow6);
        tb7 = (TableRow) findViewById(R.id.tbRow7); tb8 = (TableRow) findViewById(R.id.tbRow8);
        tb9 = (TableRow) findViewById(R.id.tbRow9); 

        etSpot = (EditText) findViewById(R.id.spotText); etDiv=(EditText) findViewById(R.id.divRate); 
        etIR= (EditText) findViewById(R.id.IR); etVol = (EditText) findViewById(R.id.ATMVOL);
        etK1= (EditText) findViewById(R.id.K1); etK2= (EditText) findViewById(R.id.K2);
        etK3= (EditText) findViewById(R.id.K3); etK4= (EditText) findViewById(R.id.K4);
        etMat1 = (EditText) findViewById(R.id.T1);etMat2 = (EditText) findViewById(R.id.T2); 
        etMat3 = (EditText) findViewById(R.id.T3);etMat4 = (EditText) findViewById(R.id.T4);
        etVol1 =(EditText) findViewById(R.id.Vol1);etVol2 =(EditText) findViewById(R.id.Vol2);
        etVol3 =(EditText) findViewById(R.id.Vol3);etVol4 =(EditText) findViewById(R.id.Vol4);
        etQty1=(EditText)  findViewById(R.id.Qty1); etQty2=(EditText)  findViewById(R.id.Qty2); 
        etQty3=(EditText)  findViewById(R.id.Qty3); etQty4=(EditText)  findViewById(R.id.Qty4);

        tvVol = (TextView) findViewById(R.id.ATM); tvSpot = (TextView) findViewById(R.id.spot);

        Del = (Button) findViewById(R.id.delBtn); Add = (Button) findViewById(R.id.addBtn);
        Price = (Button) findViewById(R.id.priceBtn);

        cbSmile = (CheckBox) findViewById(R.id.smile);

        spin1 = (Spinner) findViewById(R.id.spin1);spin2 = (Spinner) findViewById(R.id.spin2);
        spin3 = (Spinner) findViewById(R.id.spin3);spin4 = (Spinner) findViewById(R.id.spin4);
    }
    }
</code></pre>

<p>Here is the classe that I try to initialize the instance</p>

<pre><code>    package com.example.lilpricer;

public class Stock {
private double S;   

Stock(double Price){
    S=Math.abs(Price);
}

Stock(){
    this.S=0;
}
public void SetStock(double price) {
    // TODO Auto-generated method stub
    S=Math.abs(price);
}
}
</code></pre>

<p>and here is the logcat when application crashes. As you can see, it seems to be a NullPointerException in the EditText in which I input the value to initialize my object Stock, but I dont understand why I have such error since I have define an EditText in java and I linked it with the EditText of my XML page, same thing with my object (named here S), it has been defined as a global variable, so it exists.
I am obviously missing something here, but I just can't seen what it is.
Many thanks in advance for any help.</p>

<pre><code>01-06 02:06:24.770: E/AndroidRuntime(5721): FATAL EXCEPTION: main
01-06 02:06:24.770: E/AndroidRuntime(5721): java.lang.NullPointerException
01-06 02:06:24.770: E/AndroidRuntime(5721):     at com.example.lilpricer.MainActivity$1.onTextChanged(MainActivity.java:144)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.widget.TextView.sendOnTextChanged(TextView.java:7092)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.widget.TextView.handleTextChanged(TextView.java:7151)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:8794)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:962)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:496)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.text.method.NumberKeyListener.onKeyDown(NumberKeyListener.java:121)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.widget.TextView.doKeyDown(TextView.java:5246)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.widget.TextView.onKeyDown(TextView.java:5065)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.KeyEvent.dispatch(KeyEvent.java:2609)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.View.dispatchKeyEvent(View.java:7198)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.widget.HorizontalScrollView.dispatchKeyEvent(HorizontalScrollView.java:332)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:353)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1920)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1395)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.app.Activity.dispatchKeyEvent(Activity.java:2370)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1847)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3701)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3651)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2818)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.os.Looper.loop(Looper.java:137)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at android.app.ActivityThread.main(ActivityThread.java:5039)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at java.lang.reflect.Method.invokeNative(Native Method)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at java.lang.reflect.Method.invoke(Method.java:511)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-06 02:06:24.770: E/AndroidRuntime(5721):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
