MyAsync

来源:互联网 发布:《申报》数据库 编辑:程序博客网 时间:2024/05/23 19:32
class MyAsync extends AsyncTask<String,Void,String>{    @Override    protected String doInBackground(String... strings) {        return NetWordUtils.getNetjson(strings[0]);    }    @Override    protected void onPostExecute(String s) {        super.onPostExecute(s);        Gson gson = new Gson();        Bean bean = gson.fromJson(s, Bean.class);        list = bean.getResults();
//弄一个空集合  addAll进旧集合。        list1.addAll(list);    }}
lv = view.findViewById(R.id.xlistview);path = "http://gank.io/api/data/Android/10/1";new MyAsync().execute(path);instance = ImageLoader.getInstance();

lv.setXListViewListener(this);lv.setPullRefreshEnable(true);lv.setPullLoadEnable(true);lv.setAdapter(myadapter);
public void onRefresh() {    new MyAsync().execute(path);   lv.setAdapter(myadapter);    lv.stopLoadMore();    lv.stopRefresh();    lv.setRefreshTime("刚刚");}@Overridepublic void onLoadMore() {    new MyAsync().execute(path);    myadapter.notifyDataSetChanged();    lv.stopLoadMore();    lv.stopRefresh();    lv.setRefreshTime("刚刚");}

implements XListView.IXListViewListener

instance.displayImage("http://img1.imgtn.bdimg.com/it/u=594559231,2167829292&fm=27&gp=0.jpg",img);