簡體   English   中英

無法在Android Studio中編碼UTF-8的字符

[英]Unmappable character for encoding UTF-8 in 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];
}
}

我從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類中只有一個俄語單詞。 這是不可讀的。 我該如何解決?

您可以使用諸如getString(R.string.error_msg)類的資源中的字符串而不是硬編碼的字符串來修復它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM