简体   繁体   中英

Android: Strikethrough text in LIstView

I have a simple ListView , where a user must strike-through text by clicking on an item. But I don't have an idea how can I do it.

I found this method but it doesn't work in ListView:

setPaintFlags(text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

Its really hard to help you without you showing much code. What I can do is give you some easy hints. Wherever your TextView is located in your adapter, set a View.onClickListener . Assuming you are using Eclipse it will autofill it for you at a certain point. If not just search for click listeners on google and you get pretty quick results. Then in the listener's onClick method you actually add the above code that you included:

textView.setPaintFlags(textView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

That should be enough for you to go on. Good luck :)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM