Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android utf8上的希腊文本无法正确显示_Android_Encoding_Android Studio - Fatal编程技术网

android utf8上的希腊文本无法正确显示

android utf8上的希腊文本无法正确显示,android,encoding,android-studio,Android,Encoding,Android Studio,我正在用希腊文本和数据制作应用程序,但并不是每个字母都显示出来。 未显示的字母是否为空?标记,但只是空白。文件编码设置为utf8,在build.gradle中,我为utf8设置了compile 例如:阿加波ἀγαπῶ ἀγαπᾶ列表视图中的ν显示为agapóγαπγαπν。即使是XML上的按钮也没有正确显示同样的问题 截图: private void inicialization() { sound = (ImageView) findViewById(R.id.sound);

我正在用希腊文本和数据制作应用程序,但并不是每个字母都显示出来。 未显示的字母是否为空?标记,但只是空白。文件编码设置为utf8,在build.gradle中,我为utf8设置了compile

例如:阿加波ἀγαπῶ ἀγαπᾶ列表视图中的ν显示为agapóγαπγαπν。即使是XML上的按钮也没有正确显示同样的问题

截图:

  private void inicialization() {

    sound = (ImageView) findViewById(R.id.sound);
    home = (ImageView) findViewById(R.id.home);
    home.setOnClickListener(this);

    setData();

    listwords = (ListView) findViewById(R.id.listwords);
    adapter = new ArrayAdapter<String>(this, R.layout.adapteritem, R.id.greek_word, Timeslist);
    listwords.setAdapter(adapter);
    listwords.setOnItemClickListener(this);

    play = (Button) findViewById(R.id.play);
    stop = (Button) findViewById(R.id.stop);
    play.setOnClickListener(this);
    stop.setOnClickListener(this);

    tv1 = (TextView)findViewById(R.id.text1);
    tv2 = (TextView)findViewById(R.id.text2);
    tv3 = (TextView)findViewById(R.id.text3);
    tv4 = (TextView)findViewById(R.id.text4);
    tv5 = (TextView)findViewById(R.id.text5);

    setPlayer();
}

private void setData() {

    int index;
    index = getIntent().getIntExtra("index", 0);

    switch (index){
        case 0:
            if(lang){
                Timeslist = GlobalTimes.Times1ListCZ; // from global class of arrays
                TimesAudio = GlobalTimes.Times1AudioCZ;
                TimesWords = GlobalTimes.Times1WordsCZ;
            }
            if(!lang){
                Timeslist =  GlobalTimes.Times1List;
                TimesAudio = GlobalTimes.Times1Audio;
                TimesWords = GlobalTimes.Times1Words;
            }
            break;
    }
}
My adapteritem.xml

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

<TextView
    android:id="@+id/greek_word"
    android:layout_height="50dp"
    android:gravity="center_vertical"
    android:text="text"
    android:textSize="12dp"
    android:padding="3dp"
    android:visibility="visible"
    android:layout_width="fill_parent"
    android:textColor="#FF000000"
    android:background="#FFFFFFFF" />
}

编辑:问题由

!!!!!!!!!!!!!!!!!! 使用typeface Times new roman.ttf并通过重写适配器方法应用于textview!!! !!!!!!!!!!!!!!!!!!

font = Typeface.createFromAsset(getAssets(), "times.ttf");
然后让这个类的一个对象引用到一个listadapter

 public class MyAdapter extends ArrayAdapter<String> {
    public Context context;
    public String[] values;
    private Typeface font;

    public MyAdapter(Context context, String[] values, Typeface font) {
        super(context, R.layout.adapteritem, values);
        this.context = context;
        this.values = values;
        this.font = font;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View rowView = inflater.inflate(R.layout.adapteritem, parent, false);
        TextView textView = (TextView) rowView.findViewById(R.id.greek_word);

        textView.setTypeface(font);
        textView.setText(values[position]); // maybe not the best line of code but i dont know how do it better.. but works :)

        return rowView;
    }
}

也许您的编辑器Eclipse没有将文件保存为UTF-8

无论如何,这样的字符串应该存储在中。因为这些文件是XML文件,所以不太可能有编码问题

编辑:即使在Android Studio中,您也可能遇到此问题。您可以在这里查看:

这些字母是动态的还是静态数据?例如,静态数据{ἀγαπῶ, ἀγαπᾶν, ἀγαπήσω, ἠγάπησα, ἠγάπηκα, ἠγάπημαι, ἠγαπθην,miluji}你在使用文本视图吗?你可以粘贴你的代码吗?No iam将数据放入listview你不可以使用自定义listview并在textviewiam中使用Android Studio设置这些。当我右键单击Android Studio时,无论我想要什么,我选择文件编码,我将其设置为UTF8,并在Build.gradle中设置为UTF8。我已将编码设置为UTF8查看编辑。我已在你的ScreenShot尝试将一个新的文本视图放置在布局文件中直接设置文本的位置。使用其中一个字符丢失的单词。TextView是否正确呈现单词?确定。那我想可能是字体的问题。这些看不见的角色真的很特别吗?它们是否取自标准希腊字母表?你是如何构造像'这样的重音的?你的键盘上有两次击键吗?我的键盘上没有。。是的,它们很特别,因为它们不在标准的希腊语aplhabet中,因为有些角色有comas,等等。。你所说的“像”这样的上升到底是什么意思?我有捷克键盘。。但我不认为这是字体的问题,也许是,但我可以改变字体为泰晤士报新罗马显示在设备上?怎么做?会有什么不同?
font = Typeface.createFromAsset(getAssets(), "times.ttf");
 public class MyAdapter extends ArrayAdapter<String> {
    public Context context;
    public String[] values;
    private Typeface font;

    public MyAdapter(Context context, String[] values, Typeface font) {
        super(context, R.layout.adapteritem, values);
        this.context = context;
        this.values = values;
        this.font = font;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View rowView = inflater.inflate(R.layout.adapteritem, parent, false);
        TextView textView = (TextView) rowView.findViewById(R.id.greek_word);

        textView.setTypeface(font);
        textView.setText(values[position]); // maybe not the best line of code but i dont know how do it better.. but works :)

        return rowView;
    }
}