简体   繁体   中英

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". because the ArrayList that I made gets the html texts. Is there some way where I can remove the html texts before putting it in the array list?

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 
}

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