Сбой моего Android-приложения при попытке вызвать MyCursorAdapter.bindView. Вот журнал LogCat:
08-10 15:22:57.269: ERROR/AndroidRuntime(463): FATAL EXCEPTION: main
08-10 15:22:57.269: ERROR/AndroidRuntime(463): java.lang.NullPointerException
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at com.mohit.gtodo.TasksCursorAdapter.bindView(TasksCursorAdapter.java:28)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.CursorAdapter.getView(CursorAdapter.java:186)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.ListView.measureHeightOfChildren(ListView.java:1198)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.ListView.onMeasure(ListView.java:1109)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.View.measure(View.java:8171)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.View.measure(View.java:8171)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.View.measure(View.java:8171)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.View.measure(View.java:8171)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.View.measure(View.java:8171)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.os.Handler.dispatchMessage(Handler.java:99)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.os.Looper.loop(Looper.java:123)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at java.lang.reflect.Method.invokeNative(Native Method)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at java.lang.reflect.Method.invoke(Method.java:521)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-10 15:22:57.269: ERROR/AndroidRuntime(463): at dalvik.system.NativeStart.main(Native Method)
Вот метод bindView в моем CursorAdapter:
TextView title = (TextView) view.findViewById(R.id.title);
EditText body = (EditText) view.findViewById(R.id.body);
TextView created = (TextView) view.findViewById(R.id.created);
title.setText(cursor.getString(cursor.getColumnIndex(TasksDBAdapter.KEY_TITLE)));
title.setSelected(cursor.getInt(cursor.getColumnIndex(TasksDBAdapter.KEY_COMPLETED)) > 0);
body.setText(cursor.getString(cursor.getColumnIndex(TasksDBAdapter.KEY_BODY)));
created.setText(((Long)cursor.getLong(cursor.getColumnIndex(TasksDBAdapter.KEY_CREATED))).toString());
Строка 28 начинается с body.setText(cursor.getString(cursor.getColumnIndex(TasksDBAdapter.Key_BODY)));
Любая другая информация нужна?
ОБНОВЛЕНИЕ :
EditText body = (EditText) view.findViewById(R.id.body);
Кажется, будет нулевым? Вот виджет:
<EditText android:id="@+id/body" android:layout_below="@+id/body_txt" android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minLines="10"></EditText>