androidspannedfromhtml

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?


Solution

  • 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 
    }