当用户单击 listView 中的复选框时,我想在文本中设置删除线。假设我在 listView 中有三个项目,但是当我单击第一项中的复选框时,它仅在最后一项的文本中删除。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listView = (ListView) findViewById(R.id.productList);
model = helper.getAllProduct(list);
startManagingCursor(model);
listView.setAdapter(new ShoppingListAdapter(this,model));
class ShoppingListAdapter extends ResourceCursorAdapter {
public ShoppingListAdapter(Context context ,Cursor c) {
super(context,R.layout.productrow,c);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View row, Context context, Cursor c) {
// TODO Auto-generated method stub
listName = (TextView) row.findViewById(R.id.produtName);
final CheckBox listCheck=(CheckBox)row.findViewById(R.id.check);
listCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
// TODO Auto-generated method stub
if(listCheck.isChecked()){
listName.setPaintFlags(listName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
//listName.setTextColor(_context.getResources().getColor(R.color.red));
// listName.setText("go");
}
}
});
有人知道这是我的错吗?