java:
public class myMSG{
public String msg;
public boolean isChecked;
}
这是 ArrayAdapter<myMSG>.getView 中的代码
Log.e("LOGI", "init or set "+selectMsg.isChecked );
holder.mCheckBox.setSelected(selectMsg.isChecked);
Log.e("LOGI", "state "+holder.mCheckBox.isChecked() );
selectMsg 是 myMSG 类型
XML :
<TextView
android:id="@+id/tv_item_msg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_2x_15"
android:layout_weight="0.2"
android:clickable="true"
android:gravity="center"
android:textSize="@dimen/dp_2x_10"
android:text="名字"
/>
<CheckBox
android:id="@+id/cb_item_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
/>
在ArrayAdapter<myMSG>.getView 中 为Text View添加了OnClickLisener 当被点击时 改变当前 selectMsg中的
isChecked 的值 然后 调用 ArrayAdapter<myMSG>.notifyDataSetChanged()
输出的Log显示如下
public class myMSG{
public String msg;
public boolean isChecked;
}
这是 ArrayAdapter<myMSG>.getView 中的代码
Log.e("LOGI", "init or set "+selectMsg.isChecked );
holder.mCheckBox.setSelected(selectMsg.isChecked);
Log.e("LOGI", "state "+holder.mCheckBox.isChecked() );
selectMsg 是 myMSG 类型
XML :
<TextView
android:id="@+id/tv_item_msg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_2x_15"
android:layout_weight="0.2"
android:clickable="true"
android:gravity="center"
android:textSize="@dimen/dp_2x_10"
android:text="名字"
/>
<CheckBox
android:id="@+id/cb_item_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
/>
在ArrayAdapter<myMSG>.getView 中 为Text View添加了OnClickLisener 当被点击时 改变当前 selectMsg中的
isChecked 的值 然后 调用 ArrayAdapter<myMSG>.notifyDataSetChanged()
输出的Log显示如下
