Я узнал имя исключения из трассировки стека, но это все, что я смог получить, до сих пор не зная, что его вызывает и где это происходит. Итак, вот что я делаю (lstItems - это элемент управления ListView в моей деятельности:
cursor = adapter.fetchAllItems(); //that's a simple database adapter
int a = cursor.getCount();
if (cursor.getCount()!=0)
{
startManagingCursor(cursor);
String[] from = new String[] { adapter.KEY_NAME};
int[] to = new int[] { R.id.listView1 };
for (int i = 0; i < cursor.getCount(); i++)
{
SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this,
R.layout.manageItems, cursor, from, to);
lstItems.setAdapter(cursorAdapter); //that's what causing the exception, if I comment this line out, everything's fine, but the list is not updated either.
}
}
Итак, код запускается, и когда должна появиться активность с обновленным ListView, отладчик останавливается со следующей трассировкой стека:
Thread [<1> main] (Suspended (exception IllegalStateException))
ListView.layoutChildren() line: 1662
ListView(AbsListView).onLayout(boolean, int, int, int, int) line: 1147
ListView(View).layout(int, int, int, int) line: 7035
LinearLayout.setChildFrame(View, int, int, int, int) line: 1249
LinearLayout.layoutVertical() line: 1125
LinearLayout.onLayout(boolean, int, int, int, int) line: 1042
LinearLayout(View).layout(int, int, int, int) line: 7035
FrameLayout.onLayout(boolean, int, int, int, int) line: 333
FrameLayout(View).layout(int, int, int, int) line: 7035
LinearLayout.setChildFrame(View, int, int, int, int) line: 1249
LinearLayout.layoutVertical() line: 1125
LinearLayout.onLayout(boolean, int, int, int, int) line: 1042
LinearLayout(View).layout(int, int, int, int) line: 7035
PhoneWindow$DecorView(FrameLayout).onLayout(boolean, int, int, int, int) line: 333
PhoneWindow$DecorView(View).layout(int, int, int, int) line: 7035
ViewRoot.performTraversals() line: 1045
ViewRoot.handleMessage(Message) line: 1727
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]
Я подумал, что это происходит, потому что я делаю что-то не так с потоком пользовательского интерфейса, но я понятия не имею, что. Я вообще не использую несколько потоков.