批量设置button监听
private int clickButtonsIds[] = {R.id.button1,R.id.button2,R.id.button3};
button1 = (Button)findViewById(R.id.button1);
button2 = ...
button3 = ...
for (int id : clickButtonsIds){
mActivity.findViewById(id).setOnClickListener(new listeners());
}
private class listeners implements View.OnClickListener{
@Override
public void onClick(View view){
switch (view.getId()){
case R.id.button1:
break;
default:
break;
}
}
}