Is it possible to inflate a selector created in XML that will be used programmatically by StateListDrawable ?
I found that StateListDrawable has an inflate method, but I cannot find any usage examples.
It would be nice to avoid this:
StateListDrawable states = new StateListDrawable(); states.addState(new int[] {android.R.attr.state_pressed}, getResources().getDrawable(R.drawable.pressed)); states.addState(new int[] {android.R.attr.state_focused}, getResources().getDrawable(R.drawable.focused)); states.addState(new int[] { }, getResources().getDrawable(R.drawable.normal)); imageView.setImageDrawable(states);
Does anyone know if this is possible and provide an example?
Thanks in advance.
source share