Q:

Can't capture Click event for ImageButton - Android API Level 8

Problem: I am trying to capture click event of the ImageButton.
I am not able to capture the clickable event.I have used foll code
Question : Is setOnClickListener the proper way to capture ImageButton or anyother way to capture click event.
Let me know, if i can provide any more thing.
FoodType.java
public class FoodType extends Activity {

    ImageButton btnFoodType1,btnFoodType2;

    public void onCreate(Bundle bundleInstance)
    {
        super.onCreate(bundleInstance);
        setContentView(R.layout.food_type);

        btnFoodType1 = (ImageButton)findViewById(R.id.btnFoodType1);
        btnFoodType2 = (ImageButton)findViewById(R.id.btnFoodType2);

        btnFoodType1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                setContentView(R.layout.veg_category_type);
            }
        });

        btnFoodType2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                setContentView(R.layout.non_veg_category_type);
            }
        });
    }
}

Here goes the XML for the layout used.The property for ImageButton used android:clickable="true"
*food_type.xml*
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/pizza"
    android:gravity="center"
    android:orientation="horizontal" >

    <ImageButton
        android:id="@+id/btnFoodType1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="255dp"
        android:background="@drawable/veg"
        android:clickable="true"
        android:src="@drawable/ic_launcher" />

    <ImageButton
        android:id="@+id/btnFoodType2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="182dp"
        android:background="@drawable/nonveg"
        android:clickable="true"
        android:src="@drawable/ic_launcher" />

</LinearLayout>

A:

The problem is solved.
The mistake i had made is:
Mistake 1: Not entered Activity details in AndroidManifest.xml.
Mistake 2: Rather calling activity directly, I was calling layout.xml.
Actually the control was not coming from Activity 1 to Activity 2,Because I have directly called the 
setContentView(R.layout.ui2.xml); 

Mistake 1 is solved by entering the details in AndroidManifest.xml
<activity android:name="Sample"></activity>

Mistake 2 is solved by change in Activity1.java.Rather calling xml, I have called Activity2.class using Intent.
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.splash);
      entry_button = (Button) findViewById(R.id.btnEntry);
      entry_button.setOnClickListener(new View.OnClickListener() {

          @Override
          public void onClick(View view) {
              // TODO Auto-generated method stub
              // Earlier mistake commented
              // setContentView(R.layout.food_type);
              Intent splashIntent = new Intent(view.getContext(), FoodType.class);
              startActivityForResult(splashIntent, 0);
          }
    });
}

