问题
Hey, I have Arabic text in a txt file that I would like to show in a simple EditText, Though when I do that here is what I get: http://i55.tinypic.com/66g09z.png
Here is the code I use to get the text from the .txt file:
txt1 =(EditText) findViewById(R.id.EditText01);
try{
File f = new File(Environment.getExternalStorageDirectory()+"/1.txt");
FileInputStream fileIS = new FileInputStream(f);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
String readString = new String();
//just reading each line
while((readString = buf.readLine())!= null){
txt1.setText(txt1.getText().toString()+readString);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
}
How can I get proper Arabic letters into the EditText? Thanks
回答1:
What version of android do you run? Android has no support for Arabic locales up until 2.3 version. You can find more info about locales supported on corresponding SDK pages. For example, list of SDK 2.3 supported locales is here.
回答2:
You need to make sure that a font with Arabic characters is installed, and set the font of the EditText to it. The former is the annoying part. (I think I made SwiftKey do it for me by telling it to download the appropriate language modules.)
来源:https://stackoverflow.com/questions/5403615/getting-arabic-text-from-txt-file