Perform AsyncTask before displaying the Fragment
I am implementing a DrawerLayout and one of the items or the menu of the
drawer displays a gridview with images which is also a fragment.
The problem is by the time I click on the item, there is this delay or lag
before the grid of images will be showed.
Been searching for this, and I'd like to have an AsyncTask to make sure
that the GridView fragment should be completely loaded before displaying
which I need to have a ProgressDialog to prevent the lag effect or to
cover up the view. How do I check if the fragment is ready to be
displayed? How do I handle the AsyncTask? Thanks in advance.
ImageGridActivity fragment = new ImageGridActivity();
FragmentTransaction ft =
getChildFragmentManager().beginTransaction();
ft.replace(R.id.fragment_planet_replace, fragment);
Bundle args = new Bundle();
args.putStringArray(Extra.IMAGES, Constants.IMAGES);
fragment.setArguments(args);
ft.addToBackStack(null);
ft.commit();
EDIT:
I am using an `ImageAdapter` to populate the images to the listview.
`listView.setAdapter(new ImageAdapter());`
I am using Universal-Image-Loader to handle the downloading of images and
displaying it. imageLoader.displayImage
No comments:
Post a Comment