简体   繁体   English

android 中的 Html.fromHtml 是否仅适用于显示的文本?

[英]Does the Html.fromHtml in android only works in displayed texts?

Because i'm comparing the user Answer and the correct answer因为我正在比较用户答案和正确答案

if(etU1.getText().toString().equals(cquestion.get(0).getAnswer()))

Example the choice is "Brad's Drink" and even though the user types it correctly it is still wrong because the getAnswer is "Brad%$'s%# Drink".例如,选择是“Brad's Drink”,即使用户输入正确,它仍然是错误的,因为 getAnswer 是“Brad%$'s%# Drink”。 because the ArrayList that I made gets the html texts.因为我制作的 ArrayList 得到了 html 文本。 Is there some way where I can remove the html texts before putting it in the array list?有什么方法可以在将 html 文本放入数组列表之前删除它?

i think you should remove " ' " before you compare我认为你应该在比较之前删除“'”

String str = etU1.getText().toString().replaceAll("[']"," ");
String strTwo = cquestion.get(0).getAnswer().replaceAll("[']"," ");

if(str.equals(strTwo)){
////// do your logic 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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