我有一个问题,当用户点击checkbox
里面时listView
,textView
它不会收费Paint.STRIKE_THRU_TEXT_FLAG)
。当用户单击 时checkbox
,打击线将显示在 中textView
。
public void bindView(View row, Context context, Cursor c) {
// TODO Auto-generated method stub
listName = (TextView) row.findViewById(R.id.produtName);
listCheck = (CheckBox) row.findViewById(R.id.check);
Item tag = (Item) listCheck.getTag();
String pos = helper.getProductId(c);
Log.i(CN, "getView: no tag on " + pos);
tag = new Item();
tag.id = Integer.parseInt(pos);
listCheck.setTag(tag);
listCheck.setChecked(false);
String status = helper.getProductStatusT(c);
if (Integer.parseInt(status) == 0) {
listCheck.setChecked(true);
listName.setPaintFlags(listName.getPaintFlags()
| Paint.STRIKE_THRU_TEXT_FLAG);
} else {
listCheck.setChecked(false);
listName.setPaintFlags(listName.getPaintFlags()
& (~Paint.STRIKE_THRU_TEXT_FLAG));
}
public View getView(int position, View convertView, ViewGroup parent) {
View tmpView = super.getView(position, convertView, parent);
Log.i(CN, "getView:" + position);
final CheckBox cBox = (CheckBox) tmpView.findViewById(R.id.check);
Item tag = (Item) cBox.getTag();
cBox.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Item tag = (Item) v.getTag();
if (tag == null)
Log.i(CN, "checkbox clicked no tag");
else
helper.updateStatus(tag.id);
Log.i(CN, "checkbox clicked tag=" + tag.id);
}
if (cBox.isChecked()) {
Log.i(CN, " Checked!");
// do some operations here
} else {
Log.i(CN, "NOT Checked!");
// do some operations here
helper.updateStatus2(tag.id);
}
}
});
return tmpView;
}
复选框工作正常。但问题是当用户点击复选框时,罢工线不会显示出来。任何人都知道我应该把
listName.setPaintFlags(listName.getPaintFlags()| Paint.STRIKE_THRU_TEXT_FLAG);