arraylist에 약간의 문제가있어서 IndexOutOfBoundsException 예외를 피하기 위해 해결 방법이 필요합니다. 여기IndexOutOfBoundsException sharedpreferences에서 arraylist에 항목을 추가 할 때
내가 항목을 추가 해요 방법은 다음과 같습니다
내 sharedprefs는 다음과 같은 방법으로 저장됩니다for(Map.Entry<String,?> entry : getAll().entrySet()){ // this is a map with all my sharedprefs
list.add((Integer) entry.getValue(), myItem);
}
:
<int name="test0" value="0" />
<int name="test1" value="1" />
<int name="test2" value="2" />
그래서 나는에 따라 내 ArrayList의에 항목을 추가 할 필요가 int 값. 문제는 SharedPrefereces는 임의의 방법으로 값을 저장 매핑하기 때문에, 그래서
list.add((Integer) entry.getValue(), myItem);
은 그것이 해결책을 가지고 0
사람에서 시작해야하기 때문에 예외가 발생 실행될 때 온다? 감사합니다
여기서'list'를 정의합니다. –
간단한 ArrayList입니다. 그것은 유인 약을 던지지 않습니다! –
iGio90
'ArrayList arr = new ArrayList ();' –