Pergunta

I konw how to create highlight effect on listview item, this can be done by editing the selector xml file of the item background

BUT, what I want is, when user pressed the list item, not only the background change to another color, but also the color of the icon and text in the pressed item change from black to white.

I tried adding a onTouchListener to item view, change icon to white when event MotionEvent.ACTION_DOWN happened and black when event MotionEvent.ACTION_UP happened, but when user pressed an item and drag the list view, MotionEvent.ACTION_UP event will not be received thus the icon can't turn back to black

can you give some idea how to achieve this?

Foi útil?

Solução

you can get the UP event, but maybe not on the same view, or even not on the listView, but you can still handle it. for example, store the view that got the DOWN event somewhere, and when you get the UP event, handle that view and not the view you got the event on.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top