【发布时间】:2017-12-30 12:10:52
【问题描述】:
有没有人可以尝试找出我的代码中的错误?我已经尝试了很多东西,但总是以同样的错误告终。
这是我的代码:
String signeedep = spn.getSelectedItem().toString();
int a = spn1.getSelectedItemPosition();
Cursor userid = db.getallsigneenumber();
userid.moveToPosition(a);
Toast.makeText(getApplicationContext(),
userid.getString(1) + "//this is where the error points out
was assigned to the " + signeedep + ".",Toast.LENGTH_SHORT).show();
userid.close();
/*
db.open();
db.insertAssignsignee(signeedep, userid.getString(0));
db.close();
*/
myMethod();
这是我的错误:
FATAL EXCEPTION: main
android.database.CursorIndexOutOfBoundsException: Index 1 requested, with a size of 1
【问题讨论】:
-
你到底想做什么调用 getString(1) ?
-
我想获取第 1 列中的值,即 id。
-
@Justine 你的表是包含两列还是单列?
-
我加入了两个表,它们总共有 7 列。
标签: java android cursor indexoutofboundsexception toast