2014-01-13 49 views
0

我是Android开发新手。我在我的应用程序中有MultiselectionListview。我想删除所有选择的项目,但为此我必须从Sqlite调用一个函数Db.I必须以数组的形式传递选定的项目位置。我得到的位置如下:多选列表视图

SparseBooleanArray checked = lv_del.getCheckedItemPositions(); 
    for (int i= 0; i<=checked.size();i++) 
    { 
     int[] posArr = new int[checked.size()]; 
     // Item position in adapter 

     int position = checked.keyAt(i); 
     if(checked.valueAt(i)) 
     { 
      posArr [i] = (int) adapter.getItemId(position); 
     } 
    } 

} 

但它不工作,我怎么能通过数组通过选定的项目位置? 任何帮助将不胜感激。

+0

兄弟请更清楚地说明您的问题 –

+0

您的问题到底是什么?它看起来像'posArr'最终将包含您的列表中所有选中项目的'itemId'。这不是你想要的吗? – Dreagen

回答

0

您可以使用一个额外的按钮,列表视图外为OK button.And编写代码来创建使用位置数组的项目列表,并调用删除功能与在OK按钮的侦听器列表中。