unable to start an android app logact showing null pointer and classcast exception, the java file and xml file is as shown below
<p>this is the code used in tha java class.it doesnt show any errors in eclipse.the logcat shows null pointer exception and class caste exception</p>

<pre><code>package com.myfirstapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;


public class MyfirstappActivity extends Activity {
/** Called when the activity is first created. */

int count ;
Button add,sub;
TextView txt;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    count = 0;
    add = (Button) findViewById(R.id.add_one);
    sub = (Button) findViewById(R.id.sub_one);
    txt = (Button) findViewById(R.id.display);
    setContentView(R.layout.main);
    add.setOnClickListener(new View.OnClickListener() { 
        public void onClick(View v) {
            // TODO Auto-generated method stub
            count = count + 1;
            txt.setText("Your total is " + count);
        }
    });

    sub.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            count = count - 1;
            txt.setText("Your total is " + count);
        }
    }); 

}
</code></pre>

<p>this is the main.xml layout file created. i tried cleaning the project meanwhile.tried using the try catch mechanism.the app s running fine when i commented the button referncing part of the above code</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="1"&gt;

    &lt;TextView  
        android:layout_width="fill_parent" 
        android:layout_height="60dp" 
        android:text="@string/hello"
        android:id="@+id/display"
        android:textSize="40dp"
        android:gravity="center" /&gt;

   &lt;Button
       android:text="@string/add1"
       android:layout_gravity="center" 
       android:layout_width="fill_parent"
       android:layout_height="60dp"
       android:id="@+id/add_one"
       android:textSize="40dp"
       android:gravity="center"&gt;
   &lt;/Button&gt;

   &lt;Button
       android:text="@string/sub1"
       android:layout_gravity="center" 
       android:layout_width="fill_parent"
       android:layout_height="60dp"
       android:id="@+id/sub_one"
       android:textSize="40dp"
       android:gravity="center"&gt;
   &lt;/Button&gt;

&lt;/LinearLayout&gt;
</code></pre>
