2

我正在尝试在先前从数据库中填充的微调器中获取当前选定的项目。

这是我处理选择的代码:

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
4

0 回答 0