java - Display Hindi Characters on android App -
i have created document in hindi language using google indic keyboard ( not sure font characters in)
i want create property files various language , want display content is.
suppose have following file
hindi.properties
kabir=समाज सुधारक
english.properties
kabir=socoal activist
now want display these texts irrespective of font whether installed or not.
i got answers on stackoverflow setting hindi font -
textview.settypeface(typeface.createfromasset(getassets(),"fonts/hindi.ttf"));
but donesn't work me don't know font google indic keyboard uses.
anyway looking generic solution not require fonts.
for hindi make new folder inside res – values-hi/strings.xml put hindi content in , default values/string.xml support english language.
call changelocale(lang)
method whenever want change language
for hindi changelocale("hi");//change locale on selection basis
for english changelocale("en");//change locale on selection basis
//change locale
public void changelocale(string lang) { if (lang.equalsignorecase("")) return; locale mylocale = new locale(lang);//set selected locale locale.setdefault(mylocale);//set new locale default configuration config = new configuration();//get configuration config.locale = mylocale;//set config locale selected locale getbasecontext().getresources().updateconfiguration(config, getbasecontext().getresources().getdisplaymetrics());//update config }
wiki
Comments
Post a Comment