问题描述
我在setListAdapter之前使用了simple_multiple_choice来创建带有复选框的列表视图.
然后我做了确定尺寸并选择了位置:
I used before setListAdapter with simple_multiple_choice to make listview with checkboxes.
And then I did to get size and chosed positions:
SparseBooleanArray checked = list.getCheckedItemPositions();
cont = list.getCheckedItemPositions().size();
if (checked.get(i))
{
...
但是现在我需要对布局进行更多控制,所以我在xml上执行listview,例如:
But now I needed more control on the layout, so i''m doing the listview on the xml, something like:
<listview>
<checkboxes id=.../>
</listview>
对这些ID使用setAdapter.
正确填充了列表视图(如以前一样),问题是,现在SparseBooleanArray不起作用. Thar变量"cont",给我0,而"checked"为空.
确保列表"正确:
using setAdapter to those ids.
The listview is correctlyt populated (as before), problem is, now the SparseBooleanArray don''t work. Thar variable ''cont'', gives me 0, and ''checked'' is null.
To make sure that ''list'' is ok:
int len = list.getCount();
它给了我正确的价值.
是什么问题?
It gives me a right value.
What''s the problem?
推荐答案
这篇关于在ListView上获取复选框项时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!