Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save virendersran01/790c62f7186146cc187f1b5950a453ea to your computer and use it in GitHub Desktop.
Save virendersran01/790c62f7186146cc187f1b5950a453ea to your computer and use it in GitHub Desktop.
@Override
protected boolean onStateChange(int[] stateSet) {
final boolean changed = super.onStateChange(stateSet);
boolean enabled = false;
boolean pressed = false;
boolean focused = false;
boolean hovered = false;
for (int state : stateSet) {
if (state == R.attr.state_enabled) {
enabled = true;
} else if (state == R.attr.state_focused) {
focused = true;
} else if (state == R.attr.state_pressed) {
pressed = true;
} else if (state == R.attr.state_hovered) {
hovered = true;
}
}
setRippleActive(enabled && pressed);
setBackgroundActive(hovered, focused, pressed);
return changed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment