一碍脏、CheckBox與ListView的點(diǎn)擊沖突
??如果想在ListView或者GridView里面嵌套一個(gè)CheckBox或者Button或者RadioButton等等膀钠,就會(huì)有點(diǎn)擊沖突弊琴,比如想要實(shí)現(xiàn)item的點(diǎn)擊事件蛤育,而如果點(diǎn)擊了CheckBox就會(huì)響應(yīng)CheckBox的點(diǎn)擊事件荷逞,而不會(huì)觸發(fā)item的點(diǎn)擊事件道伟。
??現(xiàn)在的解決辦法就是讓item里面的控件的點(diǎn)擊事件消失迹缀,而在item的事件里面去設(shè)置CheckBox的選擇事件(設(shè)置一個(gè)布爾屬性)通過(guò)控制數(shù)據(jù)的isSelected事件,來(lái)實(shí)現(xiàn)蜜徽,點(diǎn)擊之后false-->true-->false祝懂。
?方法就是在CheckBox的布局中加入:
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false“```
## 二、CheckBox的樣式改變
在Material Design控件中使用下面代碼可以改顏色
<android.support.v7.widget.AppCompatCheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:buttonTint="@color/COLOR_HERE" />```
普通的CheckBox拘鞋,用下面代碼來(lái)改顏色:
<CheckBox android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="@color/CHECK_COLOR" />```
android:enabled="false"http://可以設(shè)置CheckBox顏色變淺
## 三砚蓬、CheckBox的默認(rèn)隱形
挖個(gè)坑,后面補(bǔ)充