Convert Figma logo to code with AI

johannilsson logoandroid-pulltorefresh

DEPRECATED This project aims to provide a reusable pull to refresh widget for Android.

2,471
1,031
2,471
39

Top Related Projects

DEPRECATED

4,015

Phoenix Pull-to-Refresh

Ultra Pull to Refresh for Android. Support all the views.

This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.

🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。

Quick Overview

Android-PullToRefresh is a library that provides a simple way to implement the "pull-to-refresh" UI pattern in Android applications. It allows users to pull down on a list or scrollable view to trigger a refresh action, commonly used for updating content in mobile apps.

Pros

  • Easy integration with existing Android projects
  • Customizable appearance and behavior
  • Supports both ListView and ScrollView
  • Lightweight and efficient implementation

Cons

  • Not actively maintained (last update was in 2014)
  • Limited compatibility with newer Android versions and material design
  • Lacks support for RecyclerView, which is now the preferred choice over ListView
  • May require additional work to integrate with modern Android architecture components

Code Examples

  1. Basic implementation with a ListView:
PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview);
pullToRefreshView.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
        // Your code to refresh the list contents
        // Make sure you call listView.onRefreshComplete() when done
        pullToRefreshView.onRefreshComplete();
    }
});
  1. Customizing the pull label:
PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview);
pullToRefreshView.getLoadingLayoutProxy().setPullLabel("Pull to refresh...");
pullToRefreshView.getLoadingLayoutProxy().setReleaseLabel("Release to refresh...");
pullToRefreshView.getLoadingLayoutProxy().setRefreshingLabel("Loading...");
  1. Using with a ScrollView:
PullToRefreshScrollView pullToRefreshView = (PullToRefreshScrollView) findViewById(R.id.pull_to_refresh_scrollview);
pullToRefreshView.setOnRefreshListener(new OnRefreshListener<ScrollView>() {
    @Override
    public void onRefresh(PullToRefreshBase<ScrollView> refreshView) {
        // Your code to refresh the content
        pullToRefreshView.onRefreshComplete();
    }
});

Getting Started

  1. Add the library to your project's build.gradle file:
dependencies {
    implementation 'com.github.johannilsson:android-pulltorefresh:0.6'
}
  1. Add the PullToRefreshListView or PullToRefreshScrollView to your layout XML:
<com.handmark.pulltorefresh.library.PullToRefreshListView
    android:id="@+id/pull_to_refresh_listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
  1. Initialize and use the PullToRefreshListView in your Activity or Fragment:
PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview);
pullToRefreshView.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
        // Your refresh logic here
        pullToRefreshView.onRefreshComplete();
    }
});

Competitor Comparisons

DEPRECATED

Pros of Android-PullToRefresh

  • More customizable with various styles and animations
  • Supports a wider range of views (ListView, GridView, WebView, ScrollView, etc.)
  • Better documentation and examples

Cons of Android-PullToRefresh

  • Larger library size due to additional features
  • Slightly more complex implementation for basic use cases
  • Last updated in 2014, potentially outdated for newer Android versions

Code Comparison

android-pulltorefresh:

PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview);
pullToRefreshView.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
        // Your code to refresh the list contents
    }
});

Android-PullToRefresh:

PullToRefreshListView mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);
mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
    @Override
    public void onRefresh(PullToRefreshBase<ListView> refreshView) {
        // Your code to refresh the list contents
    }
});

Both libraries offer similar basic functionality, but Android-PullToRefresh provides more options for customization and supports a broader range of views. However, it may be overkill for simpler projects where android-pulltorefresh could suffice. The code implementation is slightly more verbose in Android-PullToRefresh but offers more flexibility.

4,015

Phoenix Pull-to-Refresh

Pros of Phoenix

  • More visually appealing and customizable animations
  • Supports both pull-to-refresh and pull-to-load-more functionalities
  • Better performance due to optimized rendering

Cons of Phoenix

  • Larger library size, potentially increasing app size
  • Steeper learning curve due to more complex implementation
  • Less frequently updated compared to android-pulltorefresh

Code Comparison

Phoenix:

val pullToRefreshView = findViewById<PullToRefreshView>(R.id.pull_to_refresh)
pullToRefreshView.setOnRefreshListener {
    // Refresh logic here
    pullToRefreshView.setRefreshing(false)
}

android-pulltorefresh:

PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);
pullToRefreshView.setOnRefreshListener(new OnRefreshListener<ListView>() {
    @Override
    public void onRefresh(PullToRefreshBase<ListView> refreshView) {
        // Refresh logic here
        pullToRefreshView.onRefreshComplete();
    }
});

Phoenix offers a more modern, Kotlin-based implementation with a simpler listener setup, while android-pulltorefresh uses a more verbose Java approach. Phoenix's code is generally more concise and easier to read, but may require familiarity with Kotlin.

Ultra Pull to Refresh for Android. Support all the views.

Pros of android-Ultra-Pull-To-Refresh

  • More customizable and flexible, allowing for various UI styles and animations
  • Supports multiple views (ListView, GridView, ScrollView, etc.)
  • Actively maintained with recent updates and bug fixes

Cons of android-Ultra-Pull-To-Refresh

  • Slightly more complex implementation due to increased flexibility
  • Larger library size compared to android-pulltorefresh

Code Comparison

android-pulltorefresh:

PullToRefreshListView mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);
mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
    @Override
    public void onRefresh(PullToRefreshBase<ListView> refreshView) {
        // Do work to refresh the list here
    }
});

android-Ultra-Pull-To-Refresh:

PtrFrameLayout frame = (PtrFrameLayout) findViewById(R.id.store_house_ptr_frame);
frame.setPtrHandler(new PtrHandler() {
    @Override
    public void onRefreshBegin(PtrFrameLayout frame) {
        // Do work to refresh the list here
    }
});

Both libraries provide similar functionality, but android-Ultra-Pull-To-Refresh offers more customization options and supports a wider range of views. However, this comes at the cost of slightly more complex implementation and a larger library size. The code comparison shows that both libraries have similar usage patterns, with android-Ultra-Pull-To-Refresh requiring a bit more setup for advanced customization.

This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.

Pros of android-PullRefreshLayout

  • More customizable with support for custom header and footer views
  • Smoother animations and transitions during pull-to-refresh actions
  • Better support for nested scrolling views (e.g., RecyclerView, NestedScrollView)

Cons of android-PullRefreshLayout

  • Slightly more complex implementation compared to android-pulltorefresh
  • May require more setup code for advanced customizations
  • Less extensive documentation and community support

Code Comparison

android-pulltorefresh:

PullToRefreshListView mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);
mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
    @Override
    public void onRefresh(PullToRefreshBase<ListView> refreshView) {
        // Do work to refresh the list here
    }
});

android-PullRefreshLayout:

PullRefreshLayout layout = (PullRefreshLayout) findViewById(R.id.swipeRefreshLayout);
layout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
        // Do work to refresh the list here
    }
});

Both libraries offer similar basic functionality for implementing pull-to-refresh in Android applications. android-PullRefreshLayout provides more flexibility and customization options, while android-pulltorefresh offers a simpler implementation with broader community support. The choice between the two depends on the specific requirements of your project and the level of customization needed.

🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。

Pros of SmartRefreshLayout

  • More feature-rich with various refresh animations and header styles
  • Actively maintained with frequent updates and bug fixes
  • Better support for modern Android development practices and Material Design

Cons of SmartRefreshLayout

  • Larger library size due to additional features
  • Steeper learning curve for developers due to more complex API
  • May be overkill for simple pull-to-refresh implementations

Code Comparison

android-pulltorefresh:

PullToRefreshListView mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);
mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
    @Override
    public void onRefresh(PullToRefreshBase<ListView> refreshView) {
        // Do work to refresh the list here
    }
});

SmartRefreshLayout:

RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
refreshLayout.setRefreshHeader(new ClassicsHeader(this));
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh(RefreshLayout refreshlayout) {
        // Do work to refresh the list here
    }
});

Both libraries offer similar basic functionality, but SmartRefreshLayout provides more customization options and a more modern API. The code snippets demonstrate the slight differences in implementation, with SmartRefreshLayout offering more flexibility in header customization.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Pull To Refresh for Android

Note This library is deprecated, a swipe refresh layout is available in the v4 support library.


This project aims to provide a reusable pull to refresh widget for Android.

Screenshot

Repository at https://github.com/johannilsson/android-pulltorefresh.

Usage

Layout

<!--
  The PullToRefreshListView replaces a standard ListView widget.
-->
<com.markupartist.android.widget.PullToRefreshListView
    android:id="@+id/android:list"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    />

Activity

// Set a listener to be invoked when the list should be refreshed.
((PullToRefreshListView) getListView()).setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
        // Do work to refresh the list here.
        new GetDataTask().execute();
    }
});

private class GetDataTask extends AsyncTask<Void, Void, String[]> {
    ...
    @Override
    protected void onPostExecute(String[] result) {
        mListItems.addFirst("Added after refresh...");
        // Call onRefreshComplete when the list has been refreshed.
        ((PullToRefreshListView) getListView()).onRefreshComplete();
        super.onPostExecute(result);
    }
}

Last Updated

It's possible to add a last updated time using the method setLastUpdated and onRefreshComplete. The text provided to these methods will be set below the Release to refresh text. Note that the time representation is not validated replaces the previous text, which means that it's possible and recommended to add a text similar to "Last Update: 15:23". This might be changed in future versions.

1.5 Support

To use the widget on 1.5 the necessary drawables needs to be copied to that projects drawable folder. The drawables needed by the widget can be found in the drawable-hdpi folder in the library project.

Contributors

Are you using this widget?

If you are using this widget please feel free to add your app to the wiki.

License

Copyright (c) 2011 Johan Nilsson

Licensed under the Apache License, Version 2.0