Hello is it possible to have a listview containing textview be strikethrough ?
for example
if(itemText.equals("Done")){
// strikethrough here.
}else{
// no strikethrought here.
}
the thing is, when I do this the item plus the first index of the listview gets strike through
is there a way to only strike the click item ?
please help me thank you
I hope I've finally understood what you want done. But here's a shot:
You have to add an onListItemClick method like so:
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
TextView item = (TextView) v.findViewById(R.id.textView);
item.setPaintFlags(item.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
Hopefully this is what you wanted as I've got it in one of my apps and it works perfectly. Let me know! Hope it does.
I'm not 100% sure this is what you want, but to display a strikethrough text in a textview, you can:
textView.setPaintFlags(textView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
To undo the strike through:
textView.setPaintFlags(textView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.