ParseResult Exception:java.lang.IllegalStateException: Cannot add header view to list -- setAdapter
来源:互联网 发布:军团要塞2 知乎 编辑:程序博客网 时间:2024/05/18 03:52
出现这个问题往往是你在给listView. setAdapter()之后,又开始addHeaderView导致的。解决这个问题很简单,需要你交换一下顺序就可以了。就是你先addHeaderView,然后再setAdapter()。当然这个顺序在android4.3及其以后的版本就随意了。
当然遇到要动态添加headerView,也就是addHeaderView就是在setAdapter之后。不要怕还是有解决的办法。
mListView.setAdapter(null);mListView.addHeaderView(headerView);mListView.setAdapter(mAdapter);
就是这样简单,自己测试过,高低版本均有效。觉的不错顶一下哈,谢谢!
这里是一个看源码的连接,主要是将从源码分析addHeaderView
1 0
- ParseResult Exception:java.lang.IllegalStateException: Cannot add header view to list -- setAdapter
- ParseResult Exception:java.lang.IllegalStateException: Cannot add header view to list -- setAdapter
- java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been calle
- java.lang.IllegalStateException:Cannot add header view to list==setAdapter has already been called.
- java.lang.IllegalStateException:Cannot add header view to list==setAdapter has already been called.
- Cannot add header view to list -- setAdapter has already been called.
- Cannot add header view to list setAdapter has already been called
- ListView "Cannot add header view to list -- setAdapter has already been called."
- Listview:Cannot add header view to list -- setAdapter has already been called
- Cannot add header view to list -- setAdapter has already been called.
- Cannot add header view to list -- setAdapter has already been called
- ListView添加HeaderView出现Cannot add header view to list -- setAdapter has already been called.
- nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map ***
- Cannot set header. Response already committed及response.sendRedirect报java.lang.IllegalStateException的一次解决
- nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframewo
- Exception in thread "main" java.lang.IllegalStateException: Cannot get a text value from a numeric c
- java.lang.IllegalStateException: Cannot start this animator on a detached view!
- Android java.lang.IllegalStateException: Cannot start this animator on a detached view!
- Android开源特效常用链接大集合
- 【一天一道LeetCode】#122. Best Time to Buy and Sell Stock II
- 动画Animations
- SGDClassifier和LR,SVM的区别
- 数据挖掘学习笔记-分类(1)
- ParseResult Exception:java.lang.IllegalStateException: Cannot add header view to list -- setAdapter
- js 函数报错“Uncaught: TypeError xxx is not a function”
- AOP切面编程applicationContext.xml的配置
- jquery插件封装:消息对话框
- RxJava学习笔记1--RxJava原理和简单实现
- leetcode No38. Count and Say
- 学习网站
- 在Linux下面实现QDbus通信机制服务对象注册失败
- 卷1 入门CString与字符编码