简体   繁体   English

如何将布局添加到列表视图的底部?

[英]How to add a layout to the bottom of listview?

I'm trying to add two buttons to the bottom of the list view with: 我正在尝试将两个按钮添加到列表视图的底部:

footerView = ((LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.page_navigation, null, false); 
listView = (ListView) findViewById(R.id.list);
listView.addFooterView(footerView);

to this point i have no problem but when i trying to manipulate the visibility of elements of the footerview i'm getting a null pointer exception. 至此,我没有问题,但是当我尝试操纵footerview元素的可见性时,我得到了空指针异常。 according to answers in the other questions maybe using fragments is a better solution. 根据其他问题的答案,也许使用片段是更好的解决方案。 any idea how to do that 任何想法如何做到这一点

nextPage = (Button) findViewById(R.id.next);
previousPage = (Button) findViewById(R.id.prev);
mainNav = (Button) findViewById(R.id.previousNext);

above buttons are footerView elements and i'm trying to control the visibility of them and updating the listView items in response to click of this buttons (i mean is callback to this buttons available?) thanks in advance and excuse me for poor english 上面的按钮是footerView元素,我试图控制它们的可见性并响应于此按钮的单击来更新listView项(我的意思是可以使用此按钮的回调吗?)在此先感谢您,请问我英语不好

Try 尝试

nextPage = (Button) footerView.findViewById(R.id.next);
previousPage = (Button) footerView.findViewById(R.id.prev);
mainNav = (Button) footerView.findViewById(R.id.previousNext);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM