Android 如何将布局添加到listview的底部?

Android 如何将布局添加到listview的底部?,android,android-layout,android-listview,android-button,Android,Android Layout,Android Listview,Android Button,我试图在列表视图的底部添加两个按钮: footerView = ((LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.page_navigation, null, false); listView = (ListView) findViewById(R.id.list); listView.addFooterView(footerView); 到目前为止,我没有问题,

我试图在列表视图的底部添加两个按钮:

footerView = ((LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.page_navigation, null, false); 
listView = (ListView) findViewById(R.id.list);
listView.addFooterView(footerView);
到目前为止,我没有问题,但是当我试图操纵
footerview
元素的可见性时,我得到了一个空指针异常。根据其他问题的答案,也许使用片段是更好的解决方案。你知道怎么做吗

nextPage = (Button) findViewById(R.id.next);
previousPage = (Button) findViewById(R.id.prev);
mainNav = (Button) findViewById(R.id.previousNext);
上面的按钮是
footerView
元素,我试图控制它们的可见性,并更新
listView
项,以响应单击此按钮(我的意思是是否可以回调此按钮?) 提前谢谢,请原谅我英语不好

试试看

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