i have problem with styling Custom CheckBox Menu Item ActionBar. I have implemented, but It's not styled.
I want to changed with resource this
if checkbox is checked
if checkbox is not checked
this is my menu item Action Bar.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.tracking.bus.maps.SingleViewMapsActivity" >
<item
android:id="@+id/actionbar_alarm"
android:title="@string/actionbar_alarm"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/actionbar_interval"
android:title="@string/actionbar_interval"
app:actionViewClass="android.widget.Spinner"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/actionbar_log_track"
android:title="@string/actionbar_log_track"
app:showAsAction="never"/>
</menu>
style Action Bar
<style name="Theme.Myab" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">@drawable/selectable_background_myab</item>
<item name="popupMenuStyle">@style/PopupMenu.Myab</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Myab</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Myab</item>
<item name="actionDropDownStyle">@style/DropDownNav.Myab</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Myab</item>
<item name="actionModeBackground">@drawable/cab_background_top_myab</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_myab</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Myab</item>
<item name="spinnerDropDownItemStyle">@style/DropDownItem.Myab</item>
<item name="android:spinnerItemStyle">@style/SpinnerItem.Myab</item>
<item name="android:checkboxStyle">@style/customCheckBoxStyle.Myab</item>
<item name="actionBarWidgetTheme">@style/Theme.Myab.Widget</item>
</style>
<!-- style checkbox -->
<style name="customCheckBoxStyle.Myab" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/custom_checkbox_design</item>
</style>
custom_checkbox_design.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/alram_on" />
<item android:state_checked="false" android:drawable="@drawable/alram_off" />
</selector>
so how to solve it ? thanks sorry for my english
First things, android:checkboxStyle
should run on device with API 11 or later.
Try set your checkbox selector like this:
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:enterFadeDuration="300">
<item android:state_selected="true" android:drawable="@drawable/checked"></item>
<item android:state_checked="true" android:drawable="@drawable/checked"></item>
<item android:drawable="@drawable/unchecked"></item> <!--default state, unchecked-->
</selector>
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