如何使用AlertDialog正确显示非英文字符而不使用字符串资源

时间:2017-06-11 20:12:45

标签: android android-alertdialog

最好用以下简单代码解释这个问题:

AlertDialog ad = new AlertDialog.Builder(this).create();
ad.setCancelable(false); // This blocks the 'BACK' button
ad.setMessage("Italiano è" + "   "  + getString(R.string.debug));
ad.show();

其中R.stringdebug与“Italianoè”完全相同。以下是显示屏的截图:

enter image description here

只有在字符串资源中,才能看到字符“è”正确显示。

如何在硬编码字符串中正确显示?

编辑: 对于java源代码文件使用ISO-8859-1而不是UTF-8的结果:enter image description here

1 个答案:

答案 0 :(得分:0)

  

尝试这一个来处理它,而不是测试这段代码,但希望它能工作   在你的情况下

Html.fromHtml("Italiano è");