好的,我有一个持有人,持有一堆不会改变的元素,除了开关(显然)。
我减少了代码,因为它更易于阅读,我认为这将允许我在日志中看到正在更改的开关状态(从适配器动态生成)。
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
holder = new ViewHolder();
holder.communicationfilter = (Switch)convertView.findViewById(R.id.communicationfilter);
holder.communicationfilter.setChecked(!kid.isBlocked());
holder.communicationfilter.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.v(LOG_TAG, "Switch State="+isChecked);
}
});
convertView.setTag(holder);
return convertView;
}