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();
}