从 .txt 文件获取阿拉伯文本?
嘿, 我的 txt 文件中有阿拉伯文本,我想在简单的 EditText 中显示它, 虽然当我这样做时我得到的是: http://i55.tinypic.com/66g09z.png
这是我用来获取的代码.txt 文件中的文本:
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();
}
}
如何将正确的阿拉伯字母放入 EditText 中? 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要确保安装了带有阿拉伯字符的字体,并将 EditText 的字体设置为该字体。前者是令人烦恼的部分。 (我想我是通过告诉 SwiftKey 下载适当的语言模块来为我做到这一点的。)
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.)
你运行什么版本的安卓? Android 在 2.3 版本之前不支持阿拉伯语语言环境。您可以在相应的 SDK 页面上找到有关支持的区域设置的更多信息。例如,SDK 2.3 支持的语言环境列表位于此处。
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.