1

I have an ArrayList that is being read from a Text file. The array list is being displayed in a ListView. I can add and Remove items from the arraylist without an issue. I have an issue however, where the application just crashes when ever I try to modify the ArrayList. Here is the code I'm using to modify the arrayList.

input2 = (EditText) promptView.findViewById(R.id.userInput);
input2.setText(array.get(id).toString());
alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            String value2 = input2.getText().toString();
            array.set(id, value2.toString());
            adapter.notifyDataSetChanged();
        }
})

LogCat only reports an "ArrayIndexOutOfBoundsException" error. What am I doing wrong?

2
  • It means id is not in the bounds of the array. What is id? Commented Apr 13, 2014 at 10:00
  • Check the id value, I suppose it isn't an array index Commented Apr 13, 2014 at 10:00

1 Answer 1

1

You are probably mixing the id of onClick method and the id you use for indexes. Try renaming your id variable. Because the id in onClick method shows which dialog clicked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.