Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not an android design pattern. However, <a href="https://github.com/chrisbanes/Android-PullToRefresh" rel="nofollow">this</a> excellent library lets you do it easily. Have a look at the examples. </p> <p>Hope I helped.</p> <p><strong>Edit -- 12/06/2015 -- Disregard the previous statement:</strong></p> <p>This is now a design pattern that is fully supported by the SDK on Android. </p> <p>It is very simple, you need to use a <a href="https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html" rel="nofollow">SwipeRefreshLayout</a> as the parent view to your list (or other data you might want to refresh). You can put any view as a child, it will create a Pull-To-Refresh animation for that view. </p> <p>Aftewards, you just need to implement <a href="https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.OnRefreshListener.html" rel="nofollow">SwipeRefreshLayout.OnRefreshListener</a> to handle the network code of the actual data refresh:</p> <pre class="lang-java prettyprint-override"><code>public class MainActivity extends FragmentActivity implements OnRefreshListener { private SwipeRefreshLayout _pullToRefreshLayout; @Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); _pullToRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); _pullToRefreshLayout.setOnRefreshListener(this); super.onCreate(savedInstanceState); } @Override public void onRefresh() { //When this is called, your view has a little loader showing to show the user that a network call is in progress Log.i("SO17065814", "Starting refresh..."); new Handler().postDelayed(new Runnable() { @Override public void run() { mSwipeRefreshLayout.setRefreshing(false); //This stops the refresh animation Log.i("SO17065814", "Ending refresh..."); } }, 5000); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload