I have a listview activity in which I set the selector color using the following code. But when I select an item, the whole list gets highlighted with the selector color, which I don’t want. Where Am I doing wrong? Any help is appreciated.
ListView lv = getListView();
lv.setFocusableInTouchMode(true);
lv.setBackgroundColor(Color.WHITE);
lv.setSelector(R.color.blue);
Use this way to use Selector
Create a xml in
res/drawableand set the color for different event stateThen this xml as Selector
For example, let
res/drawable/selector.xmlThen declare gray in
your res\values\colors.xmlThen set selector as