我正在为 android 开发简单的购物清单应用程序。因为我能够在列表视图中删除和取消删除项目。但是在打开关闭的应用程序后,我无法获得项目的更新(保存)删除线,所有项目都从删除线中清除
这是我为 onItemClickListener 实现的部分代码
if (checkedVals[position]==true)
{
TextView text1 = (TextView)arg1.findViewById(R.id.customitemsrowTV);
text1.setPaintFlags(text1.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
text1.setTextColor(0xff000000);
String strikethrough1 = "false";
dbAdapterItems.updateItemsStrikethroughRecord(rowitemsid, strikethrough1);
//checkedVals[position] = false;
}
else
{
TextView text1 = (TextView)arg1.findViewById(R.id.customitemsrowTV);
text1.setPaintFlags(text1.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
text1.setTextColor(0xff888888);
String strikethrough1 = "true";
dbAdapterItems.updateItemsStrikethroughRecord(rowitemsid, strikethrough1);
//checkedVals[position] = true;
}
这是为列表视图填充的代码:
TextView itemsRowTv = (TextView)convertView.findViewById(R.id.customitemsrowTV);
TextView quantityRowTv = (TextView)convertView.findViewById(R.id.customquantityrowTV);
TextView priceRowTv = (TextView)convertView.findViewById(R.id.custompricerowTV);
cItems.moveToPosition(position);
String itemName = cItems.getString(1);
checkedVals[position] = Boolean.parseBoolean(cItems.getString(3));
String itemQuantity = cItems.getString(4);
String itemPrice = cItems.getString(5);
if (checkedVals[position]==true)
{
itemsRowTv.setText(itemName);
//TextView text1 = (TextView)arg1.findViewById(R.id.customitemsrowTV);
// itemsRowTv.setPaintFlags(itemsRowTv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
// itemsRowTv.setTextColor(0xff000000);
// checkedVals[position] = false;
}
else
{
// TextView text1 = (TextView)arg1.findViewById(R.id.customitemsrowTV);
itemsRowTv.setText(itemName);
itemsRowTv.setPaintFlags(itemsRowTv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
itemsRowTv.setTextColor(0xff888888);
// checkedVals[position] = true;
}
请为我的问题提出解决方案...谢谢。