Application crashes on setting two onclick listener
<p>I have placed the following code in the main activity in the onCreate method        </p>

<pre><code>public class MyTest extends Activity implements OnClickListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
 //... some other code here to init the layout
    Button btn1 = (Button)findViewById(R.id.button1);
    Button btn2 = (Button)findViewById(R.id.button2);
    btn1.setOnClickListener(this);
    btn2.setOnClickListener(this);
}
</code></pre>

<p>And have placed the following code outside the class MyTest</p>

<pre><code>@Override
public void onClick(View v) {
    switch(v.getId()){
        case R.id.button1:
            break;
        case R.id.button2:
            break;
    }
}
</code></pre>

<p>When running the application it crashes. Please can someone help me</p>
