0
我有一個提醒。代碼起作用。我有多個用於字符串的語言文件夾。 res/values/strings.xml
& res/values-es/strings.xml
等。這工作正常的用戶界面,但警報標題,按鈕標題&警報味精,我想在其他語言也。它繼續以默認語言(英語)提供。如果我嘗試使用字符串變量& getResources().getString(R.string.name);
該應用程序吹。文件說...我看到其他人已經提出了類似的問題沒有任何迴應。有人知道怎麼修這個東西嗎?指定區域設置或其他?來自字符串資源的多語言警報
public void showSettingsAlert(){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
//String title_settings = getResources().getString(R.string.Settings);
//String title_cancel = getResources().getString(R.string.Cancel);
//String GPS_settings = getResources().getString(R.string.GPS_Settings);
//String GPS_not_enabled = getResources().getString(R.string.GPS_not_enabled);
//String title_settings =getResources().getString(R.string.Settings);
// Setting Dialog Title
alertDialog.setTitle("GPS Settings");
//alertDialog.setTitle(GPS_settings);
// Setting Dialog Message
alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");
//alertDialog.setMessage(GPS_not_enabled);
// On pressing Settings button
alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
//alertDialog.setPositiveButton(settings, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
}
});
// on pressing cancel button
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
//alertDialog.setNegativeButton(cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
// Showing Alert Message
alertDialog.show();
}