我正在尝试将先前从数据库填充的微调器中的当前所选项目。
以下是处理选择的代码:
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View v,
int pos, long id) {
// TODO Auto-generated method stub
Cursor item = (Cursor) parent.getSelectedItem();
catName = item.getString(item.getColumnIndex("children")); // error on this line
Log.d("catName", "" + catName);
});
这是我的错误:
10-10 14:46:04.293: E/AndroidRuntime(12975): FATAL EXCEPTION: main
10-10 14:46:04.283: E/CursorWindow(12975): Bad request for field slot 0,-1. numRows = 42, numColumns = 2
10-10 14:46:04.293: E/AndroidRuntime(12975): java.lang.IllegalStateException: get field slot from row 0 col -1 failed