gpt4 book ai didi

android - ExpandableListView.setAdapter() 抛出 IllegalStateException

转载 作者:行者123 更新时间:2023-11-30 04:01:05 26 4
gpt4 key购买 nike

我收到以下异常:

java.lang.IllegalStateException: get field slot from row 0 col -1 failed 

当我在我的 ExpandableListView 上调用 setAdapter() 时。有人可以帮我解决这个问题吗? (我已经浪费了 2 天 :( )

Cursor mCursor = tasksListCursor(); 
Log.i("ChronicleTaskList", "rowcount: "+mCursor.getCount());
startManagingCursor(mCursor);
boolean flag = mCursor.moveToFirst();
while (flag) { // This loop executes fine.
long id = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_ID));
String name = mCursor.getString(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_NAME));
long from = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_FROM));
long to = mCursor.getLong(mCursor.getColumnIndexOrThrow(ChronicleDb.KEY_TO));
Log.i("ChronicleTaskList", id + ", "+ name+ ", "+ from+ ", "+to);
flag = mCursor.moveToNext();
}
String[] grpFromCols = { ChronicleDb.KEY_NAME};
int[] grpToVals = { R.id.cGroupRowTextName };
String[] fromCols = { TasksDbAdapter.KEY_TODODATE,
TasksDbAdapter.KEY_NAME };
int[] toVals = { R.id.textViewDate2, R.id.taskRowTextTask };

ChronicleTreeListAdapterSimple adapter = new ChronicleTreeListAdapterSimple(this, mCursor,
R.layout.c_group_row, grpFromCols, grpToVals,
R.layout.task_row2, fromCols, toVals, true);
expandableListView.setAdapter(adapter);

最后一行抛出异常。

适配器看起来像这样:

public class ChronicleTreeListAdapterSimple extends SimpleCursorTreeAdapter {
protected static String TAG = "ChronicleTreeListAdapter";

public ChronicleTreeListAdapterSimple(
ChronicleTaskList context, Cursor cursor,
int groupLayout, String[] groupFrom, int[] groupTo,
int childLayout, String[] childFrom, int[] childTo,
boolean showGroupName) {
super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childFrom, childTo);
taskList = context;
}

最佳答案

现在已经解决了。

问题出在表的主键列上,它是 “编号”.所以我把它改成了 “_id”它就像一个魅力。

这个链接给了我有关修复的提示: https://groups.google.com/forum/?fromgroups=#!topic/android-developers/Nk-lc9shUgY

关于android - ExpandableListView.setAdapter() 抛出 IllegalStateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12498820/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com