How to show Hindi text in android?

一世执手 提交于 2019-11-27 18:59:19

问题


I am trying to paste Hindi characters in an array with elements like
String[] arr = {"आपका स्वागत है","आपका स्वागत है"};
but its giving error i.e.
"some characters cannot be mapped using "Cp1252" character encoding"
while saving this.


回答1:


Switch your text encoding to UTF-8.

In Eclipse go to Window -> Preferences, select General -> Workspace. From the Text file encoding dropdown, select UTF-8.




回答2:


Thanks i found the solution...

  1. create an array under the value folder
  2. Use the font that support Hindi under the assets folder
  3. textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/Hindi.ttf")); its working fine...



回答3:


You need UTF-8 encoding, not Cp1252, and Unicode.




回答4:


Thanks i found the solution...

  1. Create an array under the value folder

  2. Use the font that support Hindi under the assets folder

  3. textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/Hindi.ttf"));

its working fine...



来源:https://stackoverflow.com/questions/5857502/how-to-show-hindi-text-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!