首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

【BUG解决】Cannot add header view to list - setAdapter has already been called

2012-09-01 
【BUG解决】Cannot add header view to list -- setAdapter has already been called.今天在为ExpandableLis

【BUG解决】Cannot add header view to list -- setAdapter has already been called.

今天在为ExpandableListView addHeaderView(加头view),运行报错:

Cannot add header view to list -- setAdapter has already been called.

?

提示我已经设置了适配器,原来addHeaderView(View v)方法 只能在父控件 setAdapter之前调用!

http://androiddada.iteye.com/

仔细想想也很容易解释,addHeaderView是为list加入 头视图,而setAdapter是为控件匹配内容。哪有先匹配了内容,再插入view的道理,皮之不存毛将焉附??

?

?

  理解了  那怎么解决呢

热点排行