0

我有 ListView,它包含一个 TextView 和一个 CheckBox。
现在,我能够在 TextView 中获取文本,这不在 TextView 的视图中,但是我无法获取不在 ListView 视图中的 CheckBox 是否被选中。

请建议我解决方案。

4

2 回答 2

0
this can be done if u can get your text information from adapter by using 
Adapter myadapter=MyList.getAdapter ;
View rowview=myadapter.getView(i,null,MyList);
now find textview by its id in rowview after that to chewck whether check box is checked or not then u can maintain booleon type array in custom adapter and maintain evrey checkbox state.
于 2012-05-08T11:59:39.590 回答
0

这已经被问了数百次了。

您无法检查这些视图的状态,因为它们不存在 - listView 创建临时视图以在需要时显示在屏幕上。解决方案是在选中/取消选中时将复选框状态保存到另一个数据源(例如数组)中,并在您的自定义适配器中使用此数组决定复选框的状态,例如 -if (suppose to be checked) checkbox.setChecked(true) else checkbox.setChecked(false)

于 2012-05-05T09:35:47.337 回答