All Products
Search
Document Center

Mobile Platform as a Service:Refresh component

Last Updated:May 18, 2021

AURefreshListView is a ListView that supports pull-down refresh and pull-up-to-load.

Dependency

See Quick start.

API description

  1. /**
  2. * Listen to the pull-down refresh state.
  3. *
  4. * @param onPullRefreshListener
  5. */
  6. public void setOnPullRefreshListener(OnPullRefreshListener onPullRefreshListener)
  7. /**
  8. * Listen to the state of loading more.
  9. *
  10. * @param onLoadMoreListener
  11. */
  12. public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener)
  13. /**
  14. * Enable pull-down refresh by using the code.
  15. */
  16. public void startRefresh()
  17. /**
  18. * End the pull-down refresh.
  19. */
  20. public void finishRefresh()
  21. /**
  22. * Update the state of loading more on the bottom.
  23. *
  24. * @param isShowLoad
  25. * @param hasMore
  26. */
  27. public void updateLoadMore(boolean isShowLoad, boolean hasMore)

Code sample

  1. <com.alipay.mobile.antui.load.AURefreshListView
  2. android:id="@+id/refresh_list_view"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content" />
  1. listView.setOnPullRefreshListener(new OnPullRefreshListener() {
  2. @Override
  3. public void onRefresh() {
  4. listView.finishRefresh();
  5. listView.updateLoadMore(true, true);
  6. }
  7. @Override
  8. public void onRefreshFinished() {
  9. }
  10. });
  11. listView.setOnLoadMoreListener(new OnLoadMoreListener() {
  12. @Override
  13. public void onLoadMore() {
  14. for (int i = 0; i < 3; i++) {
  15. Map<String, Object> map = new HashMap<String, Object>();
  16. map.put("PIC", "Pull down to load more lists");
  17. map.put("TITLE", "Pull up to load more");
  18. contents.add(map);
  19. }
  20. adapter.notifyDataSetChanged();
  21. if(contents.size() > 13) {
  22. listView.updateLoadMore(true, false);
  23. } else {
  24. listView.updateLoadMore(true, true);
  25. }
  26. }
  27. @Override
  28. public void onLoadingFinished() {
  29. }
  30. });