ITPub博客

首页 > IT职业 > IT图书 > setAdapter报ClassCastException:Linea

setAdapter报ClassCastException:Linea

IT图书 作者:ylwtsmt 时间:2021-09-09 10:05:30 0 删除 编辑

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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4505/viewspace-2816116/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-09-09

  • 博文量
    81
  • 访问量
    720