ChechTextView工作,但是当关闭应用程序并重新打开应用程序时,它们都会再次取消选中。
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// change the checkbox state
final CheckedTextView checkedTextView = ((CheckedTextView)view);
//checkedTextView.setChecked(!checkedTextView.isChecked());
if (checkedTextView.isChecked()) {
checkedTextView.setChecked(false);
checkedTextView.setPaintFlags(checkedTextView.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
else {
checkedTextView.setChecked(true);
checkedTextView.setPaintFlags(checkedTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
}
});
答案 0 :(得分:-1)
swSecuritySettings.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
if (isTouched) {
isTouched = false;
//do task
}
}
});
swSecuritySettings.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
isTouched = true;
return false;
}
});