ListView控件getCheckedItemPositions通话问题 [英] ListView getCheckedItemPositions call issue

查看:99
本文介绍了ListView控件getCheckedItemPositions通话问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与getCheckedItemPositions呼吁ListView的问题。第一次调用工作,但后续调用返回相同的结果,即使previous检查项目是听之任之。

I am having issues with the getCheckedItemPositions call for ListView. The first call works but subsequent calls returned the same results even if the previous checked items were unchecked.

如:

第一次调用:位置0安培; 1检查,结果表明0安培; 1检查
第二个呼叫:位置0安培; 1未被选中,结果仍显示0安培; 1被检查。

first call: positions 0 & 1 are checked, result shows 0 & 1 are checked 2nd call: position 0 & 1 are unchecked, result still shows 0 & 1 are checked.

这是一个错误或getCheckedItemPositions不起作用这种方式?有人可以澄清吗?谢谢!

Is this a bug or getCheckedItemPositions doesn't work this way? Can someone clarify please? Thanks!

推荐答案

使用valueAt()而不是get()方法,然后使用keyAt()来找到合适的索引到检查itmes为我工作。

Use valueAt() instead of get(), then use keyAt() to find the right index to the checked itmes works for me.

SparseBooleanArray checkedItems = lview.getCheckedItemPositions();
if (checkedItems.size() > 0) {
 for (int i=0; i<checkedItems.size(); i++) {
  if (checkedItems.valueAt(i)) {
    Log.d("checked item: " + lview.getItemAtPosition(checkedItems.keyAt(i)));
  }
 }
} 

这篇关于ListView控件getCheckedItemPositions通话问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆