我有一個ListView與適配器設置。Filter ListView通過適配器
此適配器接收對象列表。 在這些對象中,有一個屬性isActivated。 如果此屬性爲false,我不想將此項目顯示到ListView中,但我不想從通過適配器傳遞的對象列表中刪除Object。
我嘗試從適配器的getView()方法返回null,但顯然不是這樣。
我該怎麼辦?
ERROR:
questions04-01 12:21:54.290: E/AndroidRuntime(5593): FATAL EXCEPTION: main
questions04-01 12:21:54.290: E/AndroidRuntime(5593): java.lang.NullPointerException
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.ListView.fillDown(ListView.java:692)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.ListView.fillFromTop(ListView.java:750)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.ListView.layoutChildren(ListView.java:1629)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.AbsListView.onLayout(AbsListView.java:1993)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.View.layout(View.java:9606)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewGroup.layout(ViewGroup.java:3879)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.setChildFrame(LinearLayout.java:1542)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.layoutVertical(LinearLayout.java:1403)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.onLayout(LinearLayout.java:1314)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.View.layout(View.java:9606)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewGroup.layout(ViewGroup.java:3879)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.setChildFrame(LinearLayout.java:1542)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1527)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.onLayout(LinearLayout.java:1316)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.View.layout(View.java:9606)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewGroup.layout(ViewGroup.java:3879)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.setChildFrame(LinearLayout.java:1542)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.layoutVertical(LinearLayout.java:1403)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.onLayout(LinearLayout.java:1314)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.View.layout(View.java:9606)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewGroup.layout(ViewGroup.java:3879)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.FrameLayout.onLayout(FrameLayout.java:400)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.View.layout(View.java:9606)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewGroup.layout(ViewGroup.java:3879)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.setChildFrame(LinearLayout.java:1542)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.layoutVertical(LinearLayout.java:1403)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.LinearLayout.onLayout(LinearLayout.java:1314)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.View.layout(View.java:9606)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewGroup.layout(ViewGroup.java:3879)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.widget.FrameLayout.onLayout(FrameLayout.java:400)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.View.layout(View.java:9606)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewGroup.layout(ViewGroup.java:3879)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewRoot.performTraversals(ViewRoot.java:1288)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.view.ViewRoot.handleMessage(ViewRoot.java:2066)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.os.Handler.dispatchMessage(Handler.java:99)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.os.Looper.loop(Looper.java:132)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat android.app.ActivityThread.main(ActivityThread.java:4126)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat java.lang.reflect.Method.invokeNative(Native Method)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat java.lang.reflect.Method.invoke(Method.java:491)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
questions04-01 12:21:54.290: E/AndroidRuntime(5593): questionsat dalvik.system.NativeStart.main(Native Method)
你得到了什麼錯誤 – Ishu 2012-04-01 10:05:42
@nico如果你返回null,那麼任何錯誤出現? – 2012-04-01 10:20:52
@Samir是的,這是我返回null時得到的錯誤。 – Nico 2012-04-01 10:57:37