xlistview重写的俩个方法
来源:互联网 发布:淘宝网购男士夹克 编辑:程序博客网 时间:2024/06/18 12:24
@Override
public void onRefresh() {
page_num ++;
public void onRefresh() {
page_num ++;
AsyncTask<Void, Void, String> asyncTask = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... voids) {
@Override
protected String doInBackground(Void... voids) {
String path = "http://www.yulin520.com/a2a/impressApi/news/mergeList?pageSize=10&page="+page_num;
try {
URL url = new URL(path);
try {
URL url = new URL(path);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//设置
connection.setRequestMethod("GET");
connection.setReadTimeout(5000);
connection.setConnectTimeout(5000);
//设置
connection.setRequestMethod("GET");
connection.setReadTimeout(5000);
connection.setConnectTimeout(5000);
//获取
int responseCode = connection.getResponseCode();
if (responseCode == 200){
InputStream inputStream = connection.getInputStream();
int responseCode = connection.getResponseCode();
if (responseCode == 200){
InputStream inputStream = connection.getInputStream();
String json = streamToString(inputStream,"utf-8");
return json;
}
}
} catch (Exception e) {
e.printStackTrace();
}
e.printStackTrace();
}
return null;
}
}
@Override
protected void onPostExecute(String s) {
Gson gson = new Gson();
protected void onPostExecute(String s) {
Gson gson = new Gson();
DataDataBean dataDataBean = gson.fromJson(s, DataDataBean.class);
//下拉刷新的数据需要添加在大集合的最前边
list.addAll(0,dataDataBean.getData());
list.addAll(0,dataDataBean.getData());
//设置适配器...
setAdapter();
setAdapter();
//...............设置完数据之后刷新需要停止
xListView.stopRefresh();//停止刷新
xListView.stopRefresh();//停止刷新
//System.currentTimeMillis()....当前时间的long类型的值
Date date = new Date(System.currentTimeMillis());
//格式化....yyyy-MM-dd HH:mm
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
Date date = new Date(System.currentTimeMillis());
//格式化....yyyy-MM-dd HH:mm
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
//设置本次刷新的时间
xListView.setRefreshTime(simpleDateFormat.format(date));
}
};
xListView.setRefreshTime(simpleDateFormat.format(date));
}
};
asyncTask.execute();
}
}
/**
* 这是上拉加载的时候调用的方法
*
* 上拉加载更多......例如:让他请求第一页数据
*/
@Override
public void onLoadMore() {
* 这是上拉加载的时候调用的方法
*
* 上拉加载更多......例如:让他请求第一页数据
*/
@Override
public void onLoadMore() {
//再次调用
getDataFromNet();
}
getDataFromNet();
}
阅读全文
0 0
- xlistview重写的俩个方法
- xlistview用到的方法
- XListView的主方法
- xListView的主方法
- 实现XlistView的简洁方法PullToRefreshListView
- 方法的重写
- JAVA-方法的重写
- 方法重写的规则
- 方法重写的注意事项
- 虚方法的重写
- 方法的重写
- 方法的重写
- 方法的重写
- 方法的重写
- java 方法的重写
- Java方法的重写
- 方法的重写override
- equals()方法的重写
- 查找文件的类 struct _finddata_t结构体用法
- API验证
- 本地Navicat连不上Linux虚拟机MySQL数据库问题
- 数十种TensorFlow实现案例汇集:代码+笔记
- C++中换行符‘\n’和控制符‘endl’的区别(cout和printf区别)
- xlistview重写的俩个方法
- 【转】winform调用外部exe
- selenium chrome 带插件启动
- 独家 | 一文读懂社交网络分析-下(应用、前沿、学习资源)
- 最后有彩蛋,待研究
- 纯javascript 实现网页copy
- 浅谈ContextLoaderListener及其上下文与DispatcherServlet的区别
- 函数重载相关
- 在数据库Mysql中使用浮点数不要用float应当使用decimal