解决 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);


参考 :


http://blog.sina.com.cn/s/blog_6e5195850101492t.html

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

每日精进



更多相关文章

  1. No resource found that matches the given name 'android:TextA
  2. 解决 Android(安卓)模拟器 无法上网问题
  3. 解决Fetching android sdk component information加载过久问题
  4. Android(安卓)ANR问题分析思路
  5. Android使用AudioRecord遇到的问题与解决方法
  6. 报错You need to use a Theme.AppCompat theme的两种解决办法
  7. this android sdk requires android developer toolkit version
  8. 王家林的81门一站式云计算分布式大数据&移动互联网解决方案课程
  9. android直接利用opencv打开摄像头失败原因及解决方案

随机推荐

  1. 「首席看架构」CDC (捕获数据变化) Debez
  2. 从物理机“云”、集成云,到集成+原生“混
  3. 「企业微服务架构」怎么弥合不同微服务团
  4. 【数据架构】数据湖101:概述
  5. 【数据库架构】Apache Couchdb 最终一致
  6. 微服务架构系列01:容器设计原则
  7. Vue3+ElementPlus+Koa2 全栈开发后台系统
  8. 【PostgreSQL架构】为什么关系型数据库是
  9. 报告 - 麦肯锡全球研究院 分析时代:在数据
  10. 【PostgreSQL 】PostgreSQL 12的8大改进,