下拉刷新快速使用
来源:互联网 发布:一个5皇冠淘宝店多少钱 编辑:程序博客网 时间:2024/06/05 15:56
下拉刷新
下载地址http://github.com/chrisbanes/Android-pullToRefresh
//下拉刷新下载的源码
//新建项目引用
1.PullToRefreshListFragment------>添加------library库
(对着项目右键----->Properties----->选android)
2.PullToRefreshViewPager------也添加------library库
3.LauncherActivity---------------添加3个库
//新建项目-----UsingListView------也添加3个库
复制libs包写的android-support-v4.jar包分别拷入 其他的4个库包中(覆盖到原来的)
//activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<!-- library库下的PullToRefreshListView类的全称 -->
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<!-- library库下的PullToRefreshListView类的全称 -->
<com.handmark.pulltorefresh.library.PullToRefreshListView
android:id="@+id/mylv"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</com.handmark.pulltorefresh.library.PullToRefreshListView>
</LinearLayout>
//MainActivity---主程序
package com.jikexueyuan.usinglistview;
import java.util.ArrayList;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
public class MainActivity extends Activity {
private PullToRefreshListView lv;
private ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv=(PullToRefreshListView) findViewById(R.id.mylv);
List<String> arr=new ArrayList<String>();
arr.add("jikexueyuan");
arr.add("eoe");
adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,arr);
lv.setAdapter(adapter);
lv.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
//new AsyncTask<Params参数, Progress进度, Result结果>()-->Void(V要大写)
new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... params) {
try {
Thread.sleep(3000);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//在这里执行主线程的操作
@SuppressLint("NewApi")
protected void onPostExecute(Void result) {
//添加数据
adapter.addAll("Hello","大家好");
//通知listview,下载数据
lv.onRefreshComplete();
};
}.execute();//执行
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
import java.util.List;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
public class MainActivity extends Activity {
private PullToRefreshListView lv;
private ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv=(PullToRefreshListView) findViewById(R.id.mylv);
List<String> arr=new ArrayList<String>();
arr.add("jikexueyuan");
arr.add("eoe");
adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,arr);
lv.setAdapter(adapter);
lv.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
//new AsyncTask<Params参数, Progress进度, Result结果>()-->Void(V要大写)
new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... params) {
try {
Thread.sleep(3000);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//在这里执行主线程的操作
@SuppressLint("NewApi")
protected void onPostExecute(Void result) {
//添加数据
adapter.addAll("Hello","大家好");
//通知listview,下载数据
lv.onRefreshComplete();
};
}.execute();//执行
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
0 0
- 下拉刷新快速使用
- 快速使用开源库实现下拉刷新----PullRefreshLayout
- 使用MJRefresh快速集成上拉刷新及下拉刷新
- android 下拉刷新 快速实现
- android 下拉刷新使用
- 下拉刷新SwipeRefreshLayout使用
- 快速集成下拉上拉刷新demo
- 第三方下拉刷新快速集成
- 71.快速集成下拉刷新--MJRefresh
- 使用XRefreshView实现下拉刷新下拉加载
- UITableView下拉刷新的使用
- 使用EGOTableViewPullRefresh实现下拉刷新
- 下拉刷新(TableView中才可使用)
- 下拉刷新 & SBJson 的使用
- 使用EGORefreshTableHeaderView进行下拉刷新
- MJRefresh下拉刷新框架使用
- swift2 下拉刷新MJRefersh使用
- android使用SwipeRefreshLayout下拉刷新
- Ajax请求。数据的提交,参数的传递。FormCollection
- Linux trap用法介绍
- EditText实现全选和复制的功能,自定义样式只有底部才有线
- Java GBK,UTF-8编码
- QQ盗号技术
- 下拉刷新快速使用
- service如何弹出dialog
- 下拉刷新和上拉加载更多原理 .
- 小舟从此逝,江海寄馀生。
- 在项目中使用PowerBuilder来同步数据数据。
- 红米Note LTE 联通/移动4G版 官方MIUI6内核版本信息
- 让VirtualBox使用物理硬盘作为虚拟硬盘镜像
- C#多态
- 拣尽寒枝不肯栖,寂寞沙洲冷。