Java Android TextView不显示俄语符号

Java Android TextView不显示俄语符号,java,android,textview,Java,Android,Textview,我有一个txt文件(UTF-8格式)保存在res/raw。当我试图在我的应用程序的文本视图中显示它的内容时,我得到的是垃圾而不是俄罗斯符号 布局如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Text

我有一个txt文件(UTF-8格式)保存在res/raw。当我试图在我的应用程序的文本视图中显示它的内容时,我得到的是垃圾而不是俄罗斯符号

布局如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id = "@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:textSize="18sp"
        android:padding="5dp"
        android:text="@string/hello_world" />

</LinearLayout>

有没有办法正确显示俄文符号?

不幸的是,对Android的UTF-8支持不完整。我认为这些符号中的一些是否有效实际上取决于设备。请尝试将这一行(作为第一行)添加到布局中:
。它应该告诉TextView正确处理UTF-8字符
package com.example.filereader_sample;

import java.io.DataInputStream;
import java.io.InputStream;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.TextView;
import android.widget.Toast;


public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView text = (TextView) findViewById(R.id.text);

        InputStream file = getResources().openRawResource(R.raw.content);
        try {
            StringBuffer sBuffer = new StringBuffer();
            DataInputStream dataIO = new DataInputStream(file);
            String str = null;

            while ((str = dataIO.readLine()) != null)
                sBuffer.append(str + "\n");

            text.setText(sBuffer.toString());

        } catch (Exception e) {
            Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG);
        }
    }
}