I want to implement a star as a button in Android so that when a user wants to favorite their ‘current settings’ they touch the star, which then turns yellow.
How would you do this? Can you change the default button? Or can you just import the picture and then set like an OnTouchListener?
If someone could also tell me how to import a picture (star), that would be beneficial as well.
Thanks for all the help.
Declare an
ImageButtonthat has the star as it’s background. Then you can register a listener for when the button is pressed to either show or remove the star.Note: removing the star is equivalent to setting the imagebutton’s background to null in most cases.
To import the star, put it in your “res/drawables” directory and then reference it in xml or in your Java code.