The drop-down refresh list of third-party open-source frameworks (commonly used QQ )., Open-source framework

Source: Internet
Author: User

The drop-down refresh list of third-party open-source frameworks (commonly used QQ )., Open-source framework

PullToRefreshListView is a third-party open-source framework, which is used in pull-down and refresh lists.

(This open-source framework will not be updated after 2013)

Click here to download

1 package com. lixu. kaiyuanxiala; 2 3 import java. util. arrayList; 4 5 import com. handmark. pulltorefresh. library. pullToRefreshBase; 6 import com. handmark. pulltorefresh. library. pullToRefreshBase. onRefreshListener; 7 import com. handmark. pulltorefresh. library. pullToRefreshListView; 8 import android. app. activity; 9 import android. OS. asyncTask; 10 import android. OS. bundle; 11 import android. widget. arrayAdap Ter; 12 import android. widget. listView; 13 import android. widget. textView; 14 import android. widget. toast; 15 16 public class MainActivity extends Activity {17 private ArrayList <String> date; 18 private int count = 0; 19 private ArrayAdapter <String> adapter; 20 PullToRefreshListView prolactin; 21 22 @ Override23 protected void onCreate (Bundle savedInstanceState) {24 super. onCreate (savedInstanceState); 25 setConte NtView (R. layout. activity_main); 26 27 date = new ArrayList <String> (); 28 adapter = new ArrayAdapter <String> (this, android. r. layout. simple_list_item_1, date); 29 30 prolactin = (PullToRefreshListView) findViewById (R. id. 5); 31 32. setAdapter (adapter); 33 34 TextView TV = new TextView (this); 35 TV. setText ("show me the content !! "); 36 37 prolactin. setEmptyView (TV); 38 // The monitoring drop-down event is executed every time onRefresh (). 39. setOnRefreshListener (new OnRefreshListener <ListView> () {40 41 @ Override42 public void onRefresh (PullToRefreshBase <ListView> refreshView) {43 new employee cute (); 44} 45 }); 46 47} 48 49 private class MyAsync extends AsyncTask {50 @ Override51 protected void onPreExecute () {52 // start refreshing 53 prolactin. setRefreshing (); 54} 55 56 @ Override57 protected Object doInBackground (Object... params) {58 59 return Count ++; 60} 61 62 @ Override63 protected void onPostExecute (Object result) {64 Toast. makeText (getApplicationContext (), "Update successful! ", 0 ). show (); 65 date. add (0, "" + result); 66 // refresh the adapter 67 adapter. notifyDataSetChanged (); 68 // end refresh 69 prolactin. onRefreshComplete (); 70 71} 72} 73}

Xml file:

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2     xmlns:tools="http://schemas.android.com/tools" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" > 5  6     <com.handmark.pulltorefresh.library.PullToRefreshListView 7         android:id="@+id/prl" 8         android:layout_width="match_parent" 9         android:layout_height="match_parent"10          />11 12 </RelativeLayout>

Run:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.