I am using around 27 Expandable Listview(That scroll inside Scrollview, not the one that has parent, child relation) inside Scrollview(One is visible at a time, after selecting some text). I want to add load more on this, while user reached to last item while scrolling listview. But setOnScrollListener() return me last item instantly while loading data instead of Scrolling. Please suggest some way to use load more in this condition.
listViewsSearchResults[i].setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (firstVisibleItem + visibleItemCount == totalItemCount && totalItemCount != 0) {
//call API
Log.d("ListView ", alphabets[finalI] + " Hit API");
}
}
}
});
If you want to use setOnScrollListener() of Expandable Listview under scrollview, You can't use it inside scrollview, but you may have another solution as i have used and fixed my problem.
you may simply remove your Scrollview, and header layout above listview, and keep listview only in layout file. and then use your headerView as a listview headerView.
create another layout as a layout_headerview.xml and put your header content in this file,
finally set them as a headerView of listview,
write below code in your onCreate() method.
LayoutInflater layoutInflater;
View headerView;
layoutInflater = LayoutInflater.from(this);
headerView = layoutInflater.inflate(R.layout.layout_headerview, null);
//add it in your listview
listView.addHeaderView(headerView);
// to access headerView widgets you may use below,
iv_overlay = (ImageView) headerView.findViewById(R.id.iv_overlay);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.