public void loadMovieList() { MovieListAsyncTask task = new MovieListAsyncTask(this); task.execute(getUrl()); if (movieNameList.size() > 0) { footerView.showProgressBar(); } else { getListView().setVisibility(View.INVISIBLE); footerView.hide(); } progressLayout.setVisibility(View.VISIBLE); }
@Override public void succeed(List<String> movieNameList, List<String> movieUrlList, boolean hasNextPage) { this.movieNameList.addAll(movieNameList); this.movieUrlList.addAll(movieUrlList); adapter.notifyDataSetChanged(); progressLayout.setVisibility(View.INVISIBLE); listView.setVisibility(View.VISIBLE); if (hasNextPage) { footerView.showText(); } else { footerView.hide(); } if (movieNameList.size() == 0) { Toast.makeText(getActivity(), "无结果", Toast.LENGTH_LONG).show(); } }
protected void initListView() { footerView = new FooterView(getActivity()); footerView.setClickable(true); footerView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { loadNextPage(); } }); listView = getListView(); listView.addFooterView(footerView); movieNameList = new ArrayList<String>(); movieUrlList = new ArrayList<String>(); adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, movieNameList); setListAdapter(adapter); loadMovieList(); }