in my app when i click a button i am opening an Alert Dialog builder. My code is as follows
AlertDialog.Builder builder = new AlertDialog.Buil开发者_高级运维der(BannerImage.this);
final CharSequence[] items = {"Skip", "video", "Audio", "Games"};
builder.setTitle(" Funn ");
here instead of typing the items name here i want to add those name from R.strings.xml
file
but it shows some errors, as my user changes the locale i want to show different language for that i need to do like this. How to add the values from strings file...
final CharSequence[] items = {getString(R.string.skip), getString(R.string.video), getString(R.string.audio), getString(R.string.games)};
and then create your string.xml file
<resources>
<string name="skip">skip</string>
<string name="video">Video</string>
<string name="audio">Audio</string>
<string name="games">Games</string>
</resources>
<resources>
<string name="skip">Siguiente</string>
<string name="video">Video</string>
<string name="audio">Audio</string>
<string name="games">Juegos</string>
</resources>
You neeed to create seperate resource files for each language. E.G
- res/values/strings.xml - For all English strings that the application uses.
- res/values-fr/strings.xml - For all French strings that the application uses.
- res/values-ja/strings.xml - For all Japanese strings that the application uses.
Please read the Localization article for more info.
精彩评论