sqlite - Strikethrough not saving for the items in Android -
i'm developing simple shopping list application android. i'm able strikethrough & unstrike items in list view. after opening closed application i'm unable updated(saved) strikethroughs items, items cleared strikethrough's
here part of code implemented 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; }
here code populated listview:
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; }
kindly suggest solution problem things going wrong...thank u.
yes got solution after making little edits getview block: here is,
if (checkedvals[position]==true) { itemsrowtv.setpaintflags(itemsrowtv.getpaintflags() | paint.strike_thru_text_flag); itemsrowtv.settextcolor(0xff888888); } else if(checkedvals[position]==false) { itemsrowtv.setpaintflags(itemsrowtv.getpaintflags() & ~paint.strike_thru_text_flag); itemsrowtv.settextcolor(0xff000000); }
android sqlite listview strikethrough
No comments:
Post a Comment