Android Listview addHeaderView setadapter的时候莫名NullPointerException 解决

 解决  Android Listview addHeaderView setadapter的时候莫名NullPointerException 


转载请 注明   http://blog.csdn.net/aaawqqq/article/details/45953577


改代码的时候碰到的bug  



Bug 1: 


E/AndroidRuntime(15920): java.lang.RuntimeException: Unable to start activity ComponentInfo{ }: android.view.InflateException: Binary XML file line #35: Error inflating class fragment


解决思路 

碰见 Binary XML file line #35  

1  去检查了相关fragment xml配置  是否正确   

2  检查 import 包 是否是  import android.app.v4.Fragment      



Bug 2:

listview 莫名其妙 NullPointerException


E/AndroidRuntime(18769): Caused by: java.lang.NullPointerException


  at android.widget.ListView.clearRecycledState

  at android.widget.ListView.resetList


解决思路:


检查加载的header 或者  footer 的方式是否为 :


View header = getLayoutInflater().inflate(R.layout.header, null);  
View footer = getLayoutInflater().inflate(R.layout.footer, null);   


参考 :




//┏┓   ┏┓
//┏┛┻━━━┛┻┓
//┃       ┃  
//┃   ━   ┃
//┃ ┳┛ ┗┳ ┃
//┃       ┃
//┃   ┻   ┃
//┃       ┃
//┗━┓   ┏━┛
//  ┃   ┃   神兽保佑        
//  ┃   ┃   代码无BUG!
//  ┃   ┗━━━┓
//  ┃       ┣┓
//  ┃       ┏┛
//  ┗┓┓┏━┳┓┏┛
//    ┃┫┫ ┃┫┫
//    ┗┻┛ ┗┻┛

每日精进




评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值