我正在通过git hub中的Infinite Scroll Listview代码进行检查。 https://github.com/weixiao1984/Android-Infinite-Scroll-Listview。
我发现,超级关键字在Android Studio中显示为错误,而在Eclipse中则完全可以显示。
请检查以下使用超级关键字的代码。 InfiniteScrollListView.super行显示错误。由于此错误,我无法在Android Studio中构建项目。请帮我解决Android Studio问题。提前致谢。
@Override
public void setAdapter(ListAdapter adapter) {
// Force the list view to accept its own type of adapter
if (!(adapter instanceof InfiniteScrollListAdapter)) {
throw new IllegalArgumentException(InfiniteScrollListAdapter.class.getSimpleName() + " expected");
}
// Pass information to adaptor
InfiniteScrollListAdapter infiniteListAdapter = (InfiniteScrollListAdapter) adapter;
infiniteListAdapter.setLoadingMode(loadingMode);
infiniteListAdapter.setStopPosition(stopPosition);
infiniteListAdapter.setInfiniteListPageListener(this);
this.setOnScrollListener(infiniteListAdapter);
// Workaround to keep spaces for header and footer
View dummy = new View(getContext());
addLoadingView(InfiniteScrollListView.super,dummy);
super.setAdapter(adapter);
removeLoadingView(InfiniteScrollListView.super, dummy);
}
添加加载方式
//Add loading view method
private void addLoadingView(ListView listView, View loadingView) {
if (listView == null || loadingView == null) {
return;
}
// Avoid overlapping the header or footer
if (!loadingViewVisible) {
if (loadingMode == LoadingMode.SCROLL_TO_TOP) {
// Add loading view to list view header when scroll up to load
listView.addHeaderView(loadingView);
} else {
// Add loading view to list view footer when scroll down to load
listView.addFooterView(loadingView);
}
loadingViewVisible = true;
}
}
最佳答案
根据评论中的讨论。方法addLoadingView(ListView listView, View loadingView);
需要一个ListView
。如果您有InfiniteScrollListView
的实例。您可以将其传递给此方法。因为InfiniteScrollListView
是A ListView
。