从TextView中删除删除线TextView

2023-09-06 13:49:22 作者:深知是你是梦我怎敢触碰

我用这条线以下,以我的TextView中设置了删除线:

I'm using this line below in order to set a strikethrough on my TextView:

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

不过后来在片段,如果他们再次单击TextView的,我想删除线将被删除。我可以使用哪些线code简单地使TextView中再次显示在正常格式的文本?

However later on in the Fragment, if they click the TextView again, I would like the strikethrough to be removed. What line of code can I use to simply make the TextView display the text in the normal format again?

在此先感谢!

推荐答案

我最终找到本次网上:

tv.setPaintFlags(tv.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG));

这成功地消除了删除线,所以我在执行数据库的检查后, OnListItemClick 方法中调用这个我做了,看看该项目已经通过删除线(在我的情况购买)。

This successfully removes the strikethrough and therefore I called this in my OnListItemClick method after carrying out a check in the database I made to see if the item had already been striked through (purchased in my case).