Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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