Reputation: 66
I am working on project of android in eclipse.Android version is 2.3.3. I had set my button colour and I can also change colour of button when it is clicked but when my cursor is on button , button colour have to change and as cursor moves away it should have the colour which it had previously , same as hovering on button. But I can not figure out the action event such as state_pressed so I need that action event .If anyone can then please help me.
Upvotes: 1
Views: 9493
Reputation: 123
You can use xml for change state of button also refer this link Change color of button
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Button Focused-->
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/login_hover"
/>
<!-- Button Focused Pressed-->
<item android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/login_hover"
/>
<!-- Button Pressed-->
<item android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/login_hover"
/>
<!-- Button Default Image-->
<item android:drawable="@drawable/login_bg"/>
</selector>
Upvotes: 5
Reputation:
it is too easy just upload an image which may look like a button and make the image have a OnClickListener()
Upvotes: 0
Reputation: 564
What you exactly need is onfocus, onpress, onclick you want to change the color. Use selectors , this will hep you
Upvotes: 1