adapter = new ListAdapter(this) ;
listView = (ListView) findViewById(R.id.listView1) ;
new DownloadTask().execute(url,Integer.toString(pageNo) ) ;
//listView.setAdapter(adapter) ;
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
if(isScroll && (scrollState == SCROLL_STATE_IDLE)){ // 状态:0 滑动到底部
new DownloadTask().execute(url,Integer.toString(pageNo) ) ;
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
isScroll = ((firstVisibleItem + visibleItemCount) == totalItemCount) ;
System.out.println("------->"+totalItemCount) ;
}
}) ;
}
@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;
}
class DownloadTask extends AsyncTask<String, Void, List<Map<String, Object>>>{
@Override
protected List<Map<String, Object>> doInBackground(String... params) {
// TODO Auto-generated method stub
List<Map<String, Object>> list = new ArrayList<Map<String,Object>>() ;
HashMap<String, Object> map ;
HttpClient client = new DefaultHttpClient() ;
HttpGet get = new HttpGet(params[0]+params[1]) ;
try {
HttpResponse response = client.execute(get) ;
=======================================================================================
public class ListAdapter extends BaseAdapter {
List<Map<String,Object>> list ;
LayoutInflater inflater ;
public void setData(List<Map<String,Object>> data){
this.list = data ;
}
public ListAdapter(Context context) {
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>() ;
inflater = LayoutInflater.from(context) ;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.size() ;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return list.get(position) ;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position ;
}