在我的应用中,我有listview
。如果我单击列表中的某个项目,它将遍历另一个使我编辑值的意图。只有一个listitem
,它不适合我。它会关闭应用程序。我检查了logcat
。我将其视为IndexOutOfBound
例外。无法修复它。请帮帮我。
lvDetail.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id)
{
HashMap<String, String> map = new HashMap<String, String>();
map = valuesList.get(position);
DesigId = map.get(Desig_ID);
DesigName = map.get(Desig);
Desc1 = map.get(Desc);
Intent in = new Intent(ViewAndUpdate.this, EnterDetails.class);
in.putExtra("DesigId", "" + DesigId);
in.putExtra("Desig", "" + DesigName);
in.putExtra("Desc", "" + Desc1);
startActivity(in);
}
});
这是logcat
部分:
01-31 12:17:32.693: E/AndroidRuntime(2263): FATAL EXCEPTION: main
01-31 12:17:32.693: E/AndroidRuntime(2263): java.lang.IndexOutOfBoundsException: Invalid index 10, size is 10
01-31 12:17:32.693: E/AndroidRuntime(2263): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
01-31 12:17:32.693: E/AndroidRuntime(2263): at java.util.ArrayList.get(ArrayList.java:304)
答案 0 :(得分:0)
它说size is 10
表示0到9,但你的位置是10!尝试positon-1
而不是position