gpt4 book ai didi

java - onListItemClick 上的 NullPointerException

转载 作者:行者123 更新时间:2023-12-02 00:33:52 27 4
gpt4 key购买 nike

我在 ListActivity 中随机收到 nullpointerException(我无法一致地重现该错误)。 StackTrace 在第一行 super.onListItemClick() 上显示错误。不确定为什么会返回 null?

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
for (int i = 0; i < infos.size(); i++)
if (i != position)
l.getChildAt(i).setBackgroundColor(0xFF444444);
v.setBackgroundColor(0xFF666666);
// v.setClickable(true);
// test.setColorFilter(Color.parseColor("#444444"),
// PorterDuff.Mode.DARKEN);
ApplicationInfo ai = null;
ai = infos.get(position);
rinfos = findActivitiesForPackage(this, ai.packageName);
ResolveInfo ri = rinfos.get(0);
app_package_and_name = new String[] { ri.activityInfo.packageName, ri.activityInfo.name };
}

这是堆栈跟踪:

java.lang.NullPointerException
at com.sonrlabs.test.sonr.SONR.onListItemClick(SONR.java:189)
at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3763)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:1936)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)

最佳答案

删除行 super.onListItemClick(l, v,position, id);

关于java - onListItemClick 上的 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8303143/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com