While taking a course, I was instructed to make an xml selector for a Button. The course said to make a new Android xml in Eclipse, but i am using Android Studio.
Also when I custom write the code it gives me an error. It says "element selector must be declared".
Got code from here: Android: How to Make A Drawable Selector.
Does anyone know how to do this in Android Studio?
A selector may be created by invoking the open method of this class, which will use the system's default selector provider to create a new selector. A selector may also be created by invoking the openSelector method of a custom selector provider. A selector remains open until it is closed via its close method.
A selector tag basically looks for the state of the UI at the time and displays the appropriate image. This particular drawable is for a check box, when the checkbox is in the state android:state_checked="false" (i.e. when the checkbox is not checked) it uses this image: @drawable/ic_launcher_allshow.
A ColorStateList is an object you can define in XML that you can apply as a color, but will actually change colors, depending on the state of the View object to which it is applied.
Though it is already answered in the comment,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With