Skip to content

Instantly share code, notes, and snippets.

@gatlingxyz
Created June 28, 2014 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gatlingxyz/c034245484ee7c487df6 to your computer and use it in GitHub Desktop.
Save gatlingxyz/c034245484ee7c487df6 to your computer and use it in GitHub Desktop.
AsyncTask to add views to FakeListView
private class AddViewsToFakeListTask extends AsyncTask<Void, View, Void>{
private ListAdapter adapter;
private LinearLayout view;
public AddViewsToFakeListTask(LinearLayout view, ListAdapter adapter){
this.view = view;
this.adapter = adapter;
}
@Override
protected void onPreExecute() {
progress.setVisibility(View.VISIBLE);
}
@Override
protected Void doInBackground(Void... params) {
for(int i = 0; i < adapter.getCount(); i++){
publishProgress(adapter.getView(i, null, null));
}
return null;
}
@Override
protected void onProgressUpdate(View... values) {
view.addView(values[0]);
}
@Override
protected void onPostExecute(Void aVoid) {
progress.setVisibility(View.INVISIBLE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment