从原始文件夹加载带有希伯来语文本的文件后,它无法正确显示,我是如何解决的?

时间:2015-02-01 16:01:30

标签: java android

这是我的代码

public class Blogs extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.seriously);
        String line = "";
        StringBuilder finalString = new StringBuilder();
        InputStream iStream = getResources().openRawResource(R.raw.minzelostam);
        BufferedReader bReader = new BufferedReader (new InputStreamReader(iStream));

        try {
            while ((line = bReader.readLine())!=null){
                finalString.append(line);
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        TextView tv = (TextView)findViewById(R.id.tvLongText);
        tv.setText(finalString);
    }   
}

这是屏幕上的结果

enter link description here http://i58.tinypic.com/2d8p27c.jpg

问题在于用希伯来语写作,我只是不知道如何解决它。

2 个答案:

答案 0 :(得分:0)

几年前,我有类似的任务需要解决。我下载了希伯来字体并添加到项目的资产中。然后加载该字体文件并将返回的字体设置为我正在设置希伯来文本的textview。尝试类似的方法。 Here's a font that might help you

答案 1 :(得分:0)

package com.dolev.jinjer;

公共类博客扩展了活动{

Typeface tf;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.seriously);
    tf = Typeface.createFromAsset(getAssets(), "DroidSansHebrew.ttf‬");
    String line = "";
    StringBuilder finalString = new StringBuilder();
    InputStream iStream = getResources().openRawResource(R.raw.minzelostam);
    BufferedReader bReader = new BufferedReader (new InputStreamReader(iStream));

    try {
        while ((line = bReader.readLine())!=null){
            finalString.append(line);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    TextView tv = (TextView)findViewById(R.id.tvLongText);
    tv.setTypeface(tf);
    tv.setText(finalString);
}   

}

仍在努力工作:(