I am trying to make a listView with two buttons on each row. I have an adapter where the buttons and the rest views of my list are declared. My problem is that I can not fire the buttons from my main activity. I thought the code below should work but it didn't.
public class Zmenu extends Activity {
final EfficientAdapter Myadapter=new EfficientAdapter(this);
final ListView l1 = (ListView) findViewById(R.id.ListView01);
l1.setAdapter(Myadapter);
l1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
switch(arg1.getId()) {
case R.id.Button1 :
//do this block
break;
case R.id.Button2 :
//do this block
break;
}
}});
}
Can anyone helps me on what I am doing wrong in how could I fire the key listener in my main activity?