所以我有一个包含大约 10 行数据的 ListView。它渲染得很好,但是当我尝试做一个 mListView.getChildAt(index); 调用,如果结果视图低于并包括从顶部向下的第 5 行,则结果视图为 NULL。
这是我打电话的地方,一个logcat,并提前真诚地感谢您:
View r = manageTransfersList.getChildAt(mTaskIndex);
从哪里mTaskIndex
传来
public void onListItemClick(ListView l, View v, int position, long id) {
...
mTaskIndex = position;
...
}
日志猫:
08-07 09:15:12.420: E/AndroidRuntime(7657): FATAL EXCEPTION: main
08-07 09:15:12.420: E/AndroidRuntime(7657): java.lang.NullPointerException
08-07 09:15:12.420: E/AndroidRuntime(7657): at org.globus.globus.transfer.ManageTransfersFragment$TaskDetailsDialogFragment$1.onClick(ManageTransfersFragment.java:469)
08-07 09:15:12.420: E/AndroidRuntime(7657): at android.view.View.performClick(View.java:4084)
08-07 09:15:12.420: E/AndroidRuntime(7657): at android.view.View$PerformClick.run(View.java:16966)
08-07 09:15:12.420: E/AndroidRuntime(7657): at android.os.Handler.handleCallback(Handler.java:615)
08-07 09:15:12.420: E/AndroidRuntime(7657): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 09:15:12.420: E/AndroidRuntime(7657): at android.os.Looper.loop(Looper.java:137)
08-07 09:15:12.420: E/AndroidRuntime(7657): at android.app.ActivityThread.main(ActivityThread.java:4896)
08-07 09:15:12.420: E/AndroidRuntime(7657): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 09:15:12.420: E/AndroidRuntime(7657): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 09:15:12.420: E/AndroidRuntime(7657): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
08-07 09:15:12.420: E/AndroidRuntime(7657): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
08-07 09:15:12.420: E/AndroidRuntime(7657): at dalvik.system.NativeStart.main(Native Method)