文本视图显示阿拉伯语句话在断开连接方式阿拉伯语、句话、视图、文本

2023-09-06 10:19:47 作者:氣質帅比

我想显示在阿拉伯语中的句子。为了测试它,我已经使用谷歌翻译,发现在阿拉伯语中同等刑期的Hello World,这是مرحباالعالم

我已经粘贴它String.xml,并在我的code使用这样的:

  txt1.setText(getResources()的getString(R.string.sample_arabic_text)); 

但Android是在文本视图中这样显示出来(不是在连接方式):

然后我试图打印这样的文本视图的内容:

 的System.out.println(txt1.getText()); 

然后在logcat的印花纠正。

我有点糊涂了,为什么它没有得到在文本视图中正确显示。请帮我找到这个问题的解决方案。

解决方案

我通过把两个类从这个链接解决了这个问题,win7怎么调出输入法状态栏

https://github.com/agawish/Better-Arabic-Reshaper

和下面这个链接的说明:

http://blog.amr-gawish.com/39 /阿拉伯语,在机器人/

步骤:

1.Download从第一个环节的zip文件夹2.将名为ArabicReshaper,并在该包ArabicUtilities两个阶级,更改包名称,我们的应用程序的包名

之后把这个code在从第二个链接创建:

AssetManager经理= this.getAssets();

  manager.open(tahoma.ttf);TextView的电视=(TextView中)this.findViewById(R.id.testMe);tv.setTypeface(Typeface.createFromAsset(经理,tahoma.ttf));tv.setTextSize(50F);tv.setText(ArabicUtilities.reshape(adsdadsالحمدللهasdad)); 

请注意:我们必须下载tahoma.ttf,并把该资产的文件夹

I am trying to display a sentence in Arabic. For testing it I have used Google translator and found out the equivalent sentence in Arabic for "Hello World" which is مرحبا العالم

I have pasted it in "String.xml" and used it like this in my code:

txt1.setText(getResources().getString(R.string.sample_arabic_text));

But android is displaying it in text view like this (not in a connected way):

Then I tried to print the content of the text view like this:

System.out.println(txt1.getText());

Then it printed corrected in logcat.

I am bit confused why it is not getting displayed in text view correctly. Please help me to find a solution for this issue.

解决方案

I solved this issue by putting two classes from this link:

https://github.com/agawish/Better-Arabic-Reshaper

and following the instructions in this link:

http://blog.amr-gawish.com/39/arabic-language-in-android/

Steps:

1.Download the zip folder from first link 2. Put the two classes named "ArabicReshaper" and "ArabicUtilities" in to the package and change the package name to our application's package name

After that put this code in the on create from the second link:

AssetManager manager=this.getAssets();

manager.open("tahoma.ttf");
TextView tv=(TextView)this.findViewById(R.id.testMe);
tv.setTypeface(Typeface.createFromAsset(manager, "tahoma.ttf"));
tv.setTextSize(50f);
tv.setText(ArabicUtilities.reshape("adsdads الحمد لله asdad"));

Note: We have to download "tahoma.ttf" and put in the asset folder.

 
精彩推荐
图片推荐