手记

setAdapter报ClassCastException:LinearLayout$LayoutParams错误

footerView=(View)getLayoutInflater().inflate(R.layout.list_view_more, null);

listView = (ListView)this.findViewById(R.id.search_run_list);

listView.addFooterView(footerView);//注释掉这行就没问题
listView.setAdapter(mListAdapter);//报错出在这行

按照http://stackoverflow.com/questions/4393775/android-classcastexception-when-adding-a-header-view-to-expandablelistview说法


在addFooterView前加一行:

moreView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT,
    ListView.LayoutParams.WRAP_CONTENT));

这样的确能解决问题,但是没有找到上述问题的原因解释。

原文链接:http://www.apkbus.com/blog-691087-60400.html

0人推荐
随时随地看视频
慕课网APP