使用 SimpleCursorAdapter 时java.lang.IllegalArgumentException: column '_id' does not exist问题
解决思路,没有'_id',那就给它指定一个'_id'就可以了,用sql的selsect as 语句完美解决,注意此处是'_id',而不是'id'
首先,要有一个类似id列可以指定为'_id'的,我这里的dot表中是id列。
然后,自己看吧
Cursor cursor = DataSupport.findBySQL("select id as _id, submittime, address from dot order by submittime desc");
Logg.e("TAG", cursor.getColumnName(1).toString());
String[] from = {"submittime", "address"};//列名与控件id一一对应
int[] to = {R.id.fruit_time, R.id.fruit_name};
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.item_dot, cursor, from, to, CursorAdapter.FLAG_AUTO_REQUERY);
setListAdapter(mAdapter);
最重要的是第一行的as