How to change text color of simple list item

后端 未结 12 2119
清酒与你
清酒与你 2020-11-27 04:12

I have an ListActivity and i am displaying one list with:

setListAdapter(new ArrayAdapter(getApplicationContext(),
                android.R.la         


        
12条回答
  •  鱼传尺愫
    2020-11-27 04:48

    The simplest way to do this without needing to create anything extra would be to just modify the simple list TextView:

    ArrayAdapter adapter = new ArrayAdapter(this,
                    android.R.layout.simple_list_item_1, android.R.id.text1, strings) {
                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    TextView textView = (TextView) super.getView(position, convertView, parent);
                    textView.setTextColor({YourColorHere});
                    return textView;
                }
            };
    

提交回复
热议问题