为什么在此适配器的活动开始时会触发 onChekedChanged 事件?如何避免这种情况?
class ScheduleAdapter extends BaseAdapter {
SPMMainActivity context;
LayoutInflater inflater;
ArrayList<Action> actions;
OnCheckedChangeListener myCheckChangList = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
SPMManager.getSPMManager().setEnabled((Integer)buttonView.getTag() , isChecked);
Log.d("debug","onChecked...");
context.setNextAction();
SPMManager.getSPMManager().update();
}
};
...
UPD:解决方案是使用 onClick 代替
private OnClickListener checkbox_click_listener = new OnClickListener(){
public void onClick(View v) {
CheckBox c = (CheckBox) v ;
SPMManager.getSPMManager().setEnabled((Integer)v.getTag() , c.isChecked());
Log.d("onchecked","OnChecked changed");
context.setNextAction();
SPMManager.getSPMManager().update();
}
};