I am trying to implement a "button" that temporarily changes background on clicking and long-clicking. I implemented a "drawable/selector":
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/key_pressed" />
<item
android:drawable="@drawable/key_unpressed" />
</selector>
I also captured the long-click event to change the background to something else:
@Override
public boolean onLongClick(View view) {
view.setBackground(getDrawable(R.drawable.key_long_pressed));
return true;
}
Doing this makes the background stick and won't revert back. If I comment out "setBackground()", the release button works.
Ideas?
I still do want to change the background on a long click.