@Override protected void onResume() { super.onResume(); // if(flag !=null && !flag.equals("0") && !flag.equals("") // && !myApp.getCity_id().equals(flag)){ // listview.addFooterView(moreView); // youhuiquan_list.clear(); // adapter.notifyDataSetChanged(); // ListViewInFo(1); // } if (!myApp.getCity_id().equals(flag) && !myApp.getCity_id().equals("0")) { listview.addFooterView(moreView); youhuiquan_list.clear(); adapter.notifyDataSetChanged(); ListViewInFo(1); } }
public void ListViewInFo(int pangeno) { // dialog.show(); if (myApp.getCity_id() == null || myApp.getCity_id().equals("0") || myApp.getCity_id().equals("")) { // dialog.dismiss(); Toast.makeText(YouHuiQuanActivity.this, "城市没有获取到,请稍后重试", Toast.LENGTH_SHORT).show(); listview.removeFooterView(moreView); listview.onRefreshComplete(); return; } flag = myApp.getCity_id(); String url = Constants.URL_COUPON_LIST + "&city_id=" + myApp.getCity_id() + "&pagenumber=" + pangeno + "&pagesize=" + Constants.PARAM_PAGESIZE; RemoteDataHandler.asyncGet( url, new Callback() { @Override public void dataLoaded(ResponseData data) { // dialog.dismiss(); listview.onRefreshComplete(); if (data.getCode() == HttpStatus.SC_OK) { String json = data.getJson(); // if(data.getCount() <= pageno * Constants.PARAM_PAGESIZE){ // list_flag=true; // listview.removeFooterView(moreView); // }else{ // list_flag=false; // moreView.setVisibility(View.VISIBLE); // } int count = 0; if (pageno == 1) { youhuiquan_list.clear(); adapter.notifyDataSetChanged(); } else { count = ((pageno - 1) * Constants.PARAM_PAGESIZE); } listview.setSelection(count); if (data.isHasMore()) { list_flag = false; listview.addFooterView(moreView); } else { list_flag = true; listview.removeFooterView(moreView); } ArrayList<YouHuiQuanList> list = YouHuiQuanList.newInstanceList(json); youhuiquan_list.addAll(list); adapter.setDatas(youhuiquan_list); adapter.notifyDataSetChanged(); } else { listview.removeFooterView(moreView); listview.onRefreshComplete(); Toast.makeText(YouHuiQuanActivity.this, "加载优惠券列表失败,请稍后重试", Toast.LENGTH_SHORT).show(); } } }); }