![](/img/trans.png)
[英]How to use Loadmore data in android expandable listview when scroll reaches end
[英]adding listview footer when listview scroll reaches the end
我需要動態頁腳,可以在滾動視圖到達末尾時添加或刪除。 在某些時候我還需要它是可見的,而在其他時候我需要它是不可見的,因為我無法改變可見性,還有其他方法。
我有一個像這樣的滾動監聽器
listViewComments.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int i) {
if (i == AbsListView.OnScrollListener.SCROLL_STATE_IDLE
&& (listViewComments.getLastVisiblePosition() - listViewComments.getHeaderViewsCount() -
listViewComments.getFooterViewsCount()) >= (commentAdapter.getCount() - 1)) {
// removing or adding footer
}
}
當我這樣做時,即使我調用該函數一次,它也會導致頁腳閃爍,有時當我滾動它時它會進入我的列表視圖項目的中間。
您可以添加頁腳視圖:
listViewComments.addFooterView(yourFooterView);
你可以刪除它:
listViewComments.removeFooterView(yourFooterView);
不要忘記先增加頁腳視圖:
View yourFooterView = getLayoutInflater().inflate(R.layout.yourFooterXML, null);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.