Reputation: 10528
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
Upvotes: 1
Views: 3779
Reputation: 12335
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.
Upvotes: 4
Reputation: 19682
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));
Upvotes: -1