您好,登錄后才能下訂單哦!
編寫
drawable/selector_checkbox_voice.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/ic_voice_off" android:state_checked="true"/> <item android:drawable="@drawable/ic_voice_on" android:state_checked="false"/> <item android:drawable="@drawable/ic_voice_off"/> </selector>
VoiceCheckboxTheme
<!--自定義的checkbox--> <style name="VoiceCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox"> <item name="android:button">@drawable/selector_checkbox_voice</item> </style>
<CheckBox android:id="@+id/cb_voice" //這里使用 android:layout_width="@dimen/dp21" android:layout_height="@dimen/dp28" android:gravity="center" android:layout_marginLeft="@dimen/dp30" />
看左邊第二個
//點擊前
//點擊后
你可以監(jiān)聽狀態(tài):
//語音是否關(guān)閉 mCb_Voice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked){ //執(zhí)行關(guān)閉語音 MGToast.showToast("執(zhí)行關(guān)閉語音"); }else { //執(zhí)行開啟語音 MGToast.showToast("執(zhí)行開啟語音"); } } });
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。