How to use list view in the below situation? Any work arounds?

A

AC Question

In the below code, where the item’s position and title is getting saved in list_items works fine if list_items and items are ArrayList. For ex;

ArrayList.add(ArrayList.get(position));

But I am trying to use listview:
ArrayList.add(Listview.get(position));

The problem exists on line # 10

1. final Listadapter Adapter = new Listadapter(this,packageList1, packageManager);

2. items.setAdapter(Adapter);

3. items.setChoiceMode(apps.CHOICE_MODE_MULTIPLE_MODAL);

4. items.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {

5. @Override

6. public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {

7. count = count +1;

8. mode.setTitle(count + "items selected");

9. //problem resides in the below line

10. list_items.add(items.get(position));

11. }


In the above code, on selecting an item from listview I am trying to save it in an Arraylist i.e list_items which could be used in onActionItemClicked method for further action on that respective item.

Any ideas on how to solve or find a workaround to use a listview in the above situation?
 

Trending Posts

Forum statistics

Threads
943,126
Messages
6,917,391
Members
3,158,834
Latest member
steve1084