Why is ListView.getCheckedItemPositions() not returning correct values?

前端 未结 15 1973
北海茫月
北海茫月 2020-11-29 06:01

The app has a ListView with multiple-selection enabled, in the UI it works as expected. But when I read the values out using this code:

Log.         


        
15条回答
  •  忘掉有多难
    2020-11-29 06:24

    ArrayList ar_CheckedList = new ArrayList();
    

    for each holer of check box i am using to store it in array

    holder.chk_Allow.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if(isChecked)
                            ar_CheckedList.add(position);
                    }
                });
    

    on click of button

    for (int i = 0; i <  ar_CheckedList.size(); i++)
     {
            HashMap temp=(HashMap) contactList.get(ar_CheckedList.get(i));
            str_Phone_No=temp.get(TAG_CONTACT_MOBILE);
            send(str_Phone_No);
     }
    

提交回复
热议问题