Android开发:listview的addFooterView失效情况记录

来源:互联网 发布:base64加密java代码 编辑:程序博客网 时间:2024/05/05 18:54

今天在给listview添加footerView的时候,发现怎么都无法添加成功,也没有报错,以下是我的代码:


loadingFooter = inflater.inflate(R.layout.loading_footer, null);loadingFooter.setVisibility(View.VISIBLE);mListView = (ListView) view.findViewById(R.id.id_nine_listView);mListView.setAdapter(adatper);mListView.addFooterView(loadingFooter);



后来无意中调整了addFooterView的位置,就解决了,调整后代码如下:


mListView = (ListView) view.findViewById(R.id.id_nine_listView);mListView.addFooterView(loadingFooter);mListView.setAdapter(adatper);


原来是addFooterView必须在setAdapter之前才可以,原来前辈已经有说明了,是我自己不知道,链接如下:


http://stackoverflow.com/questions/4317778/hide-footer-view-in-listview

0 1
原创粉丝点击