Android的应用程序崩溃与NullPointerException异常的编舞 [英] Android app crashes with NullPointerException in ChoreoGrapher
问题描述
我有以下的code,试图在ListView创建一个简单的ListAdapter(我有这个code工作之前,这是我已经改变了的时候,唯一的地方):
I have the following code, trying to create a simple ListAdapter in a ListView (I had this code working before and this is the only place I have changed something):
public BuddyListAdapter(Context context, HashMap<String, Buddy> hashMap) {
buddyList = new ArrayList<Buddy>(hashMap.values());
mInflater = LayoutInflater.from(context);
ctx = context;
}
当单步调试,什么都不会发生,但在运行的时候,我收到了 NullPointerException异常
在 ChoreoGrapher.doCallbacks
,当我创建一个空的的ArrayList
,它不会崩溃:
When stepping through, nothing happens, but when running, I get a NullPointerException
in ChoreoGrapher.doCallbacks
, when I create an empty ArrayList
, it doesn't crash:
public BuddyListAdapter(Context context, HashMap<String, Buddy> hashMap) {
buddyList = new ArrayList<Buddy>();
mInflater = LayoutInflater.from(context);
ctx = context;
}
什么是编舞
和为什么它崩溃我的应用程序?
What is the ChoreoGrapher
and why is it crashing my app?
我完全被卡住的可能是什么问题,或如何弄清楚什么是错的。 Eclipse调试器或崩溃的信息是不是真的帮助。
I am completely stuck on what could be the problem, or how to figure out what is wrong. The Eclipse debugger or crash information is not really helping.
整个堆栈跟踪如下:
Thread [<1> main] (Suspended (exception NullPointerException))
Choreographer.doCallbacks(int, long) line: 558
Choreographer.doFrame(long, int) line: 525
Choreographer$FrameDisplayEventReceiver.run() line: 711
Handler.handleCallback(Message) line: 615
Choreographer$FrameHandler(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 137
ActivityThread.main(String[]) line: 4745
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 511
ZygoteInit$MethodAndArgsCaller.run() line: 786
ZygoteInit.main(String[]) line: 553
NativeStart.main(String[]) line: not available [native method]
我也有一个处理程序
中的主要活动。当它没有做任何事情,列表视图不会崩溃。不过,我删除它所有的回调,开扩的列表视图之前。
I also have a Handler
in the main activity. When it is not doing anything, the listview doesn't crash. However, I remove all callbacks from it before openning the listview.
推荐答案
我又在另外的应用程序一样的东西。这似乎是由未处理的异常 getView
列表中的适配器造成的。
I am having the same thing again in another application. It seems to be caused by an unhandled exception in getView
in the list adapter.
这篇关于Android的应用程序崩溃与NullPointerException异常的编舞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!