listview item background color change

后端 未结 5 691
甜味超标
甜味超标 2020-12-16 08:43

I am working on an android application. I have created a listview by using

setListAdapter(new ArrayAdapter(this,android.R.layout.simple_list_i         


        
5条回答
  •  盖世英雄少女心
    2020-12-16 09:32

    Well using this in the properties of your list view mught help:

    android:listSelector="@drawable/list_selector"
    

    It will automatically set the selected drawable as background of the selected item. Hope this works for you and drawable may be your own choice's color.

    Explanation: Add an image strip to your drawables folder/s and set that image in listSelector attribute of the your list view. Now you will navigate through your list view, the list view's background will be of the color of the image strip you set instead of android's native color. Hope you get it now...:-)

提交回复
热议问题