Button keeps force closing on me?
<p>My imageview thing keeps closing on me.</p>

<p>XML code: this is my code that places the button</p>

<pre><code>    &lt;Button
    android:id="@+id/sound" 
    android:src="@drawable/test"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" /&gt;   
</code></pre>

<p>Java code: where I have the the code for the button and it says  <code>image1.setOnClickListener(this);</code> is that is force closing it in the logcat.</p>

<pre><code>    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    main = new LinearLayout(this);  
    main.setBackgroundColor(Color.BLACK);  
    main.setLayoutParams(new LinearLayout.LayoutParams(320,480));  

    viewA = new TextView(this);  
    viewA.setBackgroundColor(Color.WHITE);  
    viewA.setTextColor(Color.BLACK);  
    viewA.setTextSize(15);
    viewA.setLayoutParams(new LinearLayout.LayoutParams(320,180));  

    main.addView(viewA);
    setContentView(main);

    Button image1 = (Button) findViewById(R.id.sound);

    image1.setOnClickListener(this);


}


public void onClick(View v) {
    switch(v.getId()){


    }
}
</code></pre>

<p>My entire code: if you need to see it so you can tell whats going on</p>

<pre><code>package dev.mrunknow.slidedirection;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.view.View;

public class SlideDirection extends Activity implements View.OnClickListener{
    /** Called when the activity is first created. */

    private LinearLayout main;      
    private TextView viewA;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        main = new LinearLayout(this);  
        main.setBackgroundColor(Color.BLACK);  
        main.setLayoutParams(new LinearLayout.LayoutParams(320,480));  

        viewA = new TextView(this);  
        viewA.setBackgroundColor(Color.WHITE);  
        viewA.setTextColor(Color.BLACK);  
        viewA.setTextSize(15);
        viewA.setLayoutParams(new LinearLayout.LayoutParams(320,180));  

        main.addView(viewA);
        setContentView(main);

        Button image1 = (Button) findViewById(R.id.sound);

        image1.setOnClickListener(SlideDirection.this);


    }


    public void onClick(View v) {
        switch(v.getId()){


        }
    }

    float x_start = 0, y_start = 0, x_end = 0, y_end = 0;

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        viewA.setText("");
        viewA.setLayoutParams(new LinearLayout.LayoutParams(320,80));
        viewA.setTextSize(40);

        int action = event.getAction();

        if (action == MotionEvent.ACTION_DOWN)
        {
            x_start = event.getX();
            y_start = event.getY();

        }

        if(action == MotionEvent.ACTION_UP)
        {
            x_end = event.getX();
            y_end = event.getY();


            if((x_start - x_end) &gt; 75 &amp;&amp; (y_start - y_end) &lt; -75)
            {
                viewA.setText("LEFT");
                Toast.makeText(this, "Left Works!", Toast.LENGTH_SHORT).show();
            }
            if((x_start - x_end) &lt; -75 &amp;&amp; (y_start - y_end) &lt; -75)
            {
                viewA.setText("RIGHT");
                Toast.makeText(this, "Right Works!", Toast.LENGTH_SHORT).show();
            }
        }
        return true;
    }



    }
</code></pre>
