Если вы расширяете свой список с помощью ListActivity, то ниже вам будет полезен
onListItemClick :
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
}
OnKeyDown:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
super.onKeyDown(keyCode, event);
switch(keyCode)
{
case KeyEvent.KEYCODE_CAMERA:
Toast.makeText(ListViewActivity.this, "Pressed Camera Button", Toast.LENGTH_SHORT).show();
return true;
case KeyEvent.KEYCODE_1:
Toast.makeText(ListViewActivity.this, "Pressed 1", Toast.LENGTH_SHORT).show();
return true;
case KeyEvent.KEYCODE_HOME:
Toast.makeText(ListViewActivity.this, "Pressed Home Button", Toast.LENGTH_SHORT).show();
return true;
case KeyEvent.KEYCODE_BACK:
Toast.makeText(ListViewActivity.this, "Pressed Back Button", Toast.LENGTH_SHORT).show();
finish();
return true;
}
return false;
}