@Override public View getView(View convertView) { View view; if (convertView == null) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.listview_row_boolean, null); TextView label = (TextView) rootView.findViewById(R.id.text_label); TrueButtonListener tListener = new TrueButtonListener(dataValue); FalseButtonListener fListener = new FalseButtonListener(dataValue); NoneButtonListener nListener = new NoneButtonListener(dataValue); CompoundButton tButton = (CompoundButton) rootView.findViewById(R.id.true_button); CompoundButton fButton = (CompoundButton) rootView.findViewById(R.id.false_button); CompoundButton nButton = (CompoundButton) rootView.findViewById(R.id.none_button); tButton.setOnCheckedChangeListener(tListener); fButton.setOnCheckedChangeListener(fListener); nButton.setOnCheckedChangeListener(nListener); holder = new BooleanRowHolder(label, tListener, fListener, nListener, tButton, fButton, nButton); rootView.setTag(holder); view = rootView; } else { view = convertView; holder = (BooleanRowHolder) convertView.getTag(); } holder.textLabel.setText(label); holder.trueButtonListener.setField(dataValue); holder.falseButtonListener.setField(dataValue); holder.noneButtonListener.setField(dataValue); holder.trueButton.setOnCheckedChangeListener(holder.trueButtonListener); holder.falseButton.setOnCheckedChangeListener(holder.falseButtonListener); holder.noneButton.setOnCheckedChangeListener(holder.noneButtonListener); if (dataValue.getValue().equals(BaseValue.FALSE)) holder.falseButton.setChecked(true); else if (dataValue.getValue().equals(BaseValue.TRUE)) holder.trueButton.setChecked(true); else if (dataValue.getValue().equals(BaseValue.EMPTY_VALUE)) holder.noneButton.setChecked(true); setEditable(editable); return view; }
@Override public void onCheckedChanged(CompoundButton button, boolean isChecked) { if (isChecked) dataValue.setValue(BaseValue.EMPTY_VALUE); }