KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Scenario:- I have two ArrayList list contains images postList contains position of selected images now when ever i am selecting the images and press delete menu ,it should delete the selected images . when i am running the code in debug ,its working fine and give the desire output. but when i am running it normal mode ,its crashing and giving above exception . if (posList.size() > 0) { Toast.makeText(getBaseContext(), "i value" +posList.size(), Toast.LENGTH_SHORT).show(); for (int i = 0; i < posList.size(); i++) appAdp.list.remove(appAdp.list.get(posList.get(i))); appAdp.notifyDataSetChanged(); posList.clear(); Toast.makeText(getBaseContext(), "You deleted selected items", Toast.LENGTH_SHORT).show(); } return true; postList values here @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { posList.add(position); error showing here appAdp.list.remove(appAdp.list.get(posList.get(i))); logcat:- java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) at java.util.ArrayList.get(ArrayList.java:304) why its behaving like this ,not getting any clue. Thanks for any help.
Tags (comma-separated)
Save Edits
Cancel