I have a problem that would be hard to explain. In my listview the list item’s have imageviews. I would like to have an ‘on click’ or ‘on pressed’ effect that changes the background of the whole list row, and also the imageviews. I tried 2 approaches:
a) defining the xml selector state list for the row’s layout
b) setting an onClickListener in java code
Option a) is no good because I can only change the items background and can’t change the imageviews (defining a state list for imageviews is no good because it only works when the exact object is touched. and I want the effect whenever any location of the row is touched)
option b) works almost correct – i set the background resource for the layout of the list item and also change the image resource for imageviews. however, afterwards they stay like that. I am now wondering how can I change back to normal to achieve the effect of a short ‘blink’ in the java code. Just like with a button – you press it and it blinks orange for a split of a second.
PS: the permanent change of resources is important, because on press I open another activity with item’s details and when I press the ‘back button’ the row looks like permanently selected.
I found a solution with using the OnTouchListener instead of onClickListener.