Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a selector in Android Studio

Tags:

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".

as you can see selector is an error

Got code from here: Android: How to Make A Drawable Selector.

Does anyone know how to do this in Android Studio?

like image 536
Menachem Hornbacher Avatar asked Jan 01 '15 19:01

Menachem Hornbacher


People also ask

How to create selector 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.

What is Selector tag android?

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.

What is color state list?

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.


1 Answers

Though it is already answered in the comment, enter image description here

like image 122
Dev Gurung Avatar answered Sep 18 '22 18:09

Dev Gurung