用于在Android Studio中编码UTF-8的不可映射字符

Zha*_*bul 2 java android utf-8 android-studio

我正在开发俄语版的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];
}
}
Run Code Online (Sandbox Code Playgroud)

我把它叫做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();
    }
}
Run Code Online (Sandbox Code Playgroud)

一切都很好,除了AlertMessage课堂上的一个俄语单词.这是不可读的.我该如何解决?

Ste*_*ngo 6

你可以通过使用资源中的字符串来getString(R.string.error_msg)代替硬编码字符串来修复它.