今天在给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