if you click on a button in android, then it become orange, how would you make it stay like that in java? I tried setBackgroundcolor, but it change the shape of my button to the default shape when i use it and i dont want that.
It not Possible for button as it does not have permanent focus but you can take one radio button and use android:button="@drawable/yourselector" . In Radio button you will get checked event and Radio Button checked is permanent state
Make a layout in res/draw able
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:state_pressed="true"
android:drawable="@drawable/btn_attending_h" /> <!--clicked-->
<item android:drawable="@drawable/btn_attending"/> <!--not clicked-->
</selector>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.