Special characters in a TextView

前端 未结 6 889
孤城傲影
孤城傲影 2020-12-09 20:35

I want to show the \"♫\" character in an Android TextView, but it shows [] instead.

This is my code:

txtCatname.setText(\"♫\");
         


        
6条回答
  •  孤城傲影
    2020-12-09 21:32

    Try this:

    String str = "♫";
    byte spbyte[] = str.getBytes("UTF-8"); 
    str = new String( spbyte,"UTF-8");
    txtCatname.setText(str);
    

    If it doesn't work, try this:

    String str = "♫";
    txtCatname.setText(Html.fromHtml(str));
    

提交回复
热议问题