How to set a button in selected/focussed mode
if (!btn.isSelected()){
btn.setSelected(true);
//...Handle toggle off
} else {
btn.setSelected(true);
//...Handled toggle on
}
xml should be placed in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@drawable/icontpcrkupsactive" />
<item
android:drawable="@drawable/icontopcrkups" />
</selector>
Check the above conditions------------for selected state...
Android Training in kerala--A Complete android tutorial blog.
if (!btn.isSelected()){
btn.setSelected(true);
//...Handle toggle off
} else {
btn.setSelected(true);
//...Handled toggle on
}
xml should be placed in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@drawable/icontpcrkupsactive" />
<item
android:drawable="@drawable/icontopcrkups" />
</selector>
Check the above conditions------------for selected state...
Android Training in kerala--A Complete android tutorial blog.
0 comments: