【问题标题】:Unmappable character for encoding UTF-8 in Android Studio在 Android Studio 中编码 UTF-8 的不可映射字符
【发布时间】:2015-07-26 19:24:54
【问题描述】:

我正在开发一个俄语版的 Android 应用。

这是我的AlertMessage 课程,其中只有一种方法和一个俄语单词:

public class AlertMessage {

public static boolean isYes (Context context, String header, String message){
    final boolean[] isYes = {false};
    new AlertDialog.Builder(context)
            .setTitle(header)
            .setMessage(message)
            .setNegativeButton(android.R.string.no, null)
            .setPositiveButton("Да",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface arg0, int arg1) {

                            isYes[0] =  true;

                        }
                    }).create().show();
    return isYes[0];
}
}

我从MainActivity 调用它:

 @Override
public void onBackPressed(){

    if(AlertMessage.isYes(this,"Выход","Вы уверены, что хотите выйти из аккаунта?"))
    {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        App.super.onBackPressed();
        Log.i("App", "Exit");
        finish();
    }
}

除了AlertMessage 类中的一个俄语单词外,一切正常。 这是不可读的。我该如何解决?

【问题讨论】:

  • 不可读是什么意思?根本不显示?它是否显示错误的字符?你说的是标题、文本还是按钮文本?
  • @TimoSta 我说的是AlertMessage 中的单词。它的编码错误,这就是它不可读的原因
  • 在strings.xml中外部化你的字符串

标签: java android utf-8 android-studio


【解决方案1】:

您可以使用来自getString(R.string.error_msg) 等资源的字符串而不是硬编码字符串来修复它。

【讨论】:

    猜你喜欢
    • 2014-07-03
    • 2015-02-15
    • 2011-06-27
    • 1970-01-01
    • 1970-01-01
    • 2014-11-21
    • 1970-01-01
    • 2014-06-15
    相关资源
    最近更新 更多