ListView.setOnScrollListener(android.widget.AbsListView$OnScrollListener)' on a null object referenc

今天为试着做一个软件管理的app,然后就为listview加入了OnScrollListener,发现会提示如下错误:



                                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rentalphang/com.example.rentalphang.activity.AppManagerActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setOnScrollListener(android.widget.AbsListView$OnScrollListener)' on a null object reference
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2356)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2418)
                                                                              at android.app.ActivityThread.access$900(ActivityThread.java:154)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:135)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5289)
                                                                              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:904)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
                                                                           Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setOnScrollListener(android.widget.AbsListView$OnScrollListener)' on a null object reference
                                                                              com.example.rentalphang.activity.AppManagerActivity.initUI(AppManagerActivity.java:249)
                                                                              com.example.rentalphang.activity.AppManagerActivity.onCreate(AppManagerActivity.java:57)
                                                                              at android.app.Activity.performCreate(Activity.java:5990)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2418) 
                                                                              at android.app.ActivityThread.access$900(ActivityThread.java:154) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5289) 
                                                                              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:904) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) 


下意识谷歌,然后没没找到满意答案。然后只能自己琢磨,listview.onscrollistener空对象,就很可能是listview出了问题,然后就想会不会没有findviewbyid吧,麻鸡,一找发现还真是,麻鸡。写这篇博文,也是希望也有这个问题的朋友解决问题,我想不会有吧,犯傻了。还有找BUG我以后还是先自己想一下怎样解决,挺能锻炼人的。想不出再百度。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值