无法从通过DB填充的微调器中获取所选项目

时间:2012-10-10 13:57:41

标签: android cursor spinner

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

以下是处理选择的代码:

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

0 个答案:

没有答案