Android : How to update the selector(StateListDrawable) programmatically

You need to use the negative value of the needed state.
E.g.:

states.addState(new int[] {-android.R.attr.state_enabled},R.drawable.btn_disabled);

Notice the “-” sign before android.R.attr.state_enabled.

Leave a Comment