I am working on multi languages UI. My requirement is in spinner I want to show data in Hindi but when it will be selected it should return english show it can compare to further decision making. Just like tag with tag.
My java code is something like this
HashMap<String,String> options=new HashMap<String,String>();
String optionsEnglish [] = getResources().getStringArray(R.array.option_array);
String optinsHindi[]= getResources().getStringArray(R.array.option_array_hindi);
for(int i=0;i<optionsEnglish.length;i++)
{
options.put(optionsEnglish[i], optinsHindi[i]);
}
Spinner optionSpinner = (Spinner) findViewById(R.id.optionPicker);
ArrayAdapter<HashMap<String, String>> dataAdapter = new ArrayAdapter<HashMap<String,String>>(this, android.R.layout.simple_spinner_item);
dataAdapter.add(options);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
optionSpinner.setAdapter(dataAdapter);
In xml
<resource>
<string-array name="option_array">
<item>Market</item>
<item>Commodity</item>
</string-array>
<string-array name="option_array_hindi">
<item>बाजार</item>
<item>वस्तु</item>
</string-array>
</resources>