2012-04-05 338 views
3

我想將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> 

回答

0

這是因爲Android的支持不包括阿拉伯字體呢。在顯示正確之前,您必須自行在固定設備上安裝字體。如果它在標準設備上,現在就忘記它。

1

您可以將字體文件(Arebic_Font.ttf)放入資源文件夾並編寫以下代碼以將解析的相關標題顯示到TextView小部件中。

TextView mTitleTextView = (TextView)findViewById(R.id.title);  
Typeface mTypeface = Typeface.createFromAsset(getAssets(),"Arebic_Font.ttf"); 
mTitleTextView.setTypeface(getDefaultTypeFace()); 

注:無須根設備新字體,只有如果字體是預定義的,我們有字體資源的.TTF文件。