I've seen all the questions which have similar problems, but in all solutions Drawables are used. I don't want to use an Image or a Drawable.
I have a custom round Button
. By default its color is set to #00796B
.
Now when the Button is clicked it should change the color to #00695C
for example and as soon as it gets released it should change back to the default color.
What do I have to do in onClickListener
event of Button to achieve what I want?
Below is my code.
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Vibrator mvibrate = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
mvibrate.vibrate(500);
}
});
I want to know that if there is any way we can use if condition to check the state of button and according to it do action?
EDIT :- I have successfully achieve what i wanted. Thanks guys for your answer and support.