How to change text color of simple list item

后端 未结 12 2111
清酒与你
清酒与你 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:47

    Another simplest way is to create a layout file containing the textview you want with textSize, textStyle, color etc preferred by you and then use it with the ArrayAdapter.

    e.g. mytextview.xml

    
    
    

    and then use it with your ArrayAdapter as usual like

    ListView lst = new ListView(context);
    String[] arr = {"Item 1","Item 2"};
    ArrayAdapter ad = new ArrayAdapter(context,R.layout.mytextview,arr);
    lst.setAdapter(ad);
    

    This way you won't need to create a custom adapter for it.

提交回复
热议问题