我正在浏览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;
}
}
答案 0 :(得分:1)
根据评论中的讨论。方法addLoadingView(ListView listView, View loadingView);
需要ListView
。如果您有InfiniteScrollListView
的实例。您可以将其传递给此方法。因为InfiniteScrollListView
是A ListView
。