我开发了一个带有firebase的Android应用程序,它运行良好。我决定用websocket而不是Firebase重用我的代码。在一些帮助下,我正在开发它,并且它进展顺利。但我有一个组件的问题。
当我在一个活动中尝试打开一个包含带有android.r.layout.simple_list_item_multiple_choice的列表视图的对话框时出现了麻烦。在那一刻,应用程序崩溃了......错误显示出来了。
我调试在对话框中加载信息的代码并显示没有错误...我找不到空对象或'由'引起的,通常它有助于找到可能是错误的位置......
06-12 00:59:56.718 2289-2289/wazodevs.com.coletask E/AndroidRuntime: FATAL EXCEPTION: main
Process: wazodevs.com.coletask, PID: 2289
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java)
at android.widget.AbsListView.obtainView(AbsListView.java)
at android.widget.ListView.makeAndAddView(ListView.java)
at android.widget.ListView.fillDown(ListView.java)
at android.widget.ListView.fillFromTop(ListView.java)
at android.widget.ListView.layoutChildren(ListView.java)
at android.widget.AbsListView.onLayout(AbsListView.java)
at android.view.View.layout(View.java)
at android.view.ViewGroup.layout(ViewGroup.java)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java)
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java)
at android.widget.LinearLayout.onLayout(LinearLayout.java)
at android.view.View.layout(View.java)
at android.view.ViewGroup.layout(ViewGroup.java)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java)
at android.widget.LinearLayout.onLayout(LinearLayout.java)
at android.view.View.layout(View.java)
at android.view.ViewGroup.layout(ViewGroup.java)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java)
at android.view.View.layout(View.java)
at android.view.ViewGroup.layout(ViewGroup.java)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
at android.widget.FrameLayout.onLayout(FrameLayout.java)
at android.view.View.layout(View.java)
at android.view.ViewGroup.layout(ViewGroup.java)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
at android.widget.FrameLayout.onLayout(FrameLayout.java)
at android.view.View.layout(View.java)
at android.view.ViewGroup.layout(ViewGroup.java)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java)
at android.widget.LinearLayout.onLayout(LinearLayout.java)
at android.view.View.layout(View.java)
at android.view.ViewGroup.layout(ViewGroup.java)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java)
at android.widget.FrameLayout.onLayout(FrameLayout.java)
at android.view.View.layout(View.java)
at android.view.ViewGroup.layout(ViewGroup.java)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java)
at android.view.Choreographer.doCallbacks(Choreographer.java)
at android.view.Choreographer.doFrame(Choreographer.java)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
06-12 00:59:57.008 356-1014/? E/BandwidthController: No such appUid 10117 to remove
Thx 4 all!
答案 0 :(得分:0)
我在对话框中调试加载信息的代码并在没有显示的情况下显示 错误...我无法找到空对象或由'引起的'通常 它有助于找到错误的位置......
您的数据集包含空值。在内部,ArrayAdapter执行以下检查:
final T item = getItem(position);
if (item instanceof CharSequence) {
text.setText((CharSequence) item);
} else {
text.setText(item.toString());
}
这是createViewFromResource
上toString
被称为
答案 1 :(得分:0)
答案非常愚蠢....问题是我必须创建一个字符串列表来加载arrayadapter,而aImages有8个元素,但是ObtainImgs过滤并填充8个中的3个...但是没有& #39; t检查员上的null ...但是当你试图继续......坠毁...... Thx伙计们!
String [] listArray = new String [aImages.length]; listArray = obtainImgs(listArray);