добавлен.

у сделать очень простую вещь. В моем приложении есть список, в который я динамически добавляю текст. Но после определенного момента я бы хотел изменить цвет текста внутри списка. Итак, я создал XML, определяющий мой пользовательский элемент списка, и вложил в него подкласс ArrayAdapter. Но всякий раз, когда я вызываю метод add () в моем собственном ArrayAdapter, элемент добавляется в представление списка, но текст в него не помещается.

Вот мой XML:

<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list_content" android:textSize="8pt"
    android:gravity="center" android:layout_margin="4dip"
    android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#FF00FF00"/>

И мой подкласс ArrayAdapter:

private class customAdapter extends ArrayAdapter<String> {
    public View v;
    public customAdapter(Context context){  
        super(context, R.layout.gamelistitem);
    }

    @Override
    public View getView(int pos, View convertView, ViewGroup parent){
        this.v = convertView;
        if(v==null) {
            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v=vi.inflate(R.layout.gamelistitem, null);
        }

        if(timeLeft!=0) {
            TextView tv = (TextView)v.findViewById(R.id.list_content);
            //tv.setText(str[pos]);
            tv.setTextColor(Color.GREEN);
        }
        else {
            TextView tv = (TextView)v.findViewById(R.id.list_content);
            //tv.setText(str[pos]);
            tv.setTextColor(Color.RED);
        }

        return v;
    }
}

Я уверен, что я делаю что-то ужасно неправильно, но я все еще немного новичок в Android.

Спасибо! `

Ответы на вопрос(1)

Ваш ответ на вопрос