我的以下代码有问题:
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick (View v) {
int row = position +1;
int listLength = data.size();
HashMap<String,String> nextRow = data.get(position+1);
if (row < listLength ) {
nextRow.put("greyedOut","false");
} else {
System.out.println("HATSIKIDEE!!");
}
notifyDataSetChanged();
System.out.println(row);
System.out.println(listLength);
}
});
此代码放置在 myAdapter
并调整ListView
,它适用于每一行,但在选择最后一行返回以下错误时崩溃:java.lang.IndexOutOfBoundsException: Invalid index 9, size is 9
我不明白的是 System.out.println() 的输出是根据 if 语句:
1 of 9
2 of 9
3 of 9
4 of 9
5 of 9
6 of 9
7 of 9
8 of 9
At 9 of 9 it crashes.
Please help me how to solve this error.