I have, for the time being, a custom view with a 9-patch image as a border.
That custom view is placed three times in a LinearLayout, so it looks like this:
+------------------------+
| CustomView |
+------------------------+
| CustomView |
+------------------------+
| CustomView |
+------------------------+
I have attached a click event listener to the View, so it is clickable. But then I click it, I can’t see that I am clicking it – there is no change in color.
So, I’m thought that I’d attach a “onPress” listener, and then change the background of the view but I couldn’t find such a listener.
So, how do I create the behaviour on the View so I can see that it is being pressed? this is normally done in Android with a green background to indicate that it is now being pressed.
You could set the OnClickListener for the view. That will be called when the view is clicked. But for something as simple as changing the background when a view is clicked you should use a stateful drawable. They work like this, you make 3 9-patch images.
Then you create an new xml file in your drawable folder. It should look like this:
Then, when you set the background of your view set it to the xml file.