问题现象:
当有几排chechebox的时候,你总会发现:在点击一个checkbox的时候其它的checkbox状态在发生改变,问题的本质是焦点所致。
解决方法:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginTop="15dip"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/cb_so2"
style="@style/Theme.AdjustCB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="SO2"
android:textColor="@android:color/white" />
<CheckBox
android:id="@+id/cb_no"
style="@style/Theme.AdjustCB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="NO"
android:textColor="@android:color/white" />
<CheckBox
android:id="@+id/cb_no2"
style="@style/Theme.AdjustCB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="NO2"
android:textColor="@android:color/white" />
</LinearLayout>
即将CheckBox设置为:android:focusable="false" android:focusableInTouchMode="false"