DOM解析Android
问题描述:
我想将XML解析为android,这里是我的xml。当我去我的XML的链接,它让我看到特殊字符罚款(阿拉伯语字母)..但是当我运行我的应用程序,它让我奇怪的字符DOM解析Android
<?xml version="1.0" encoding="ISO-8859-6"?>
<music>
<song>
<id>1</id>
<title> السلام عليكم هلا </title>
<artist>نعم</artist>
<duration>4:44</duration>
<plays>234</plays>
<thumb_url>http://api.androidhive.info/music/images/adele.png</thumb_url>
</song>
</music>
答
这是因为Android的支持不包括阿拉伯字体呢。在显示正确之前,您必须自行在固定设备上安装字体。如果它在标准设备上,现在就忘记它。
答
您可以将字体文件(Arebic_Font.ttf)放入资源文件夹并编写以下代码以将解析的相关标题显示到TextView小部件中。
TextView mTitleTextView = (TextView)findViewById(R.id.title);
Typeface mTypeface = Typeface.createFromAsset(getAssets(),"Arebic_Font.ttf");
mTitleTextView.setTypeface(getDefaultTypeFace());
注:有无须根设备新字体,只有如果字体是预定义的,我们有字体资源的.TTF文件。