Possible Duplicate:
How can I dynamically add images to a GridView?
In my application, it allows users to download images from the server and store it into the internal storage. Right after the download completed, the gridview did not update and display the images that downloaded from the server. Unless I restart the application or the activity go through onCreate()
. Is there anyway that I can update the gridview dynamically right after the application completed the download process? I tried to refresh the view with invalidateView(); also it's not working. Any comments will be appreciated.
OnCreate()
final GridView imagegrid = (GridView) findViewById(R.id.WebImageGrid);
imageAdapter = new ImageAdapter();
imagegrid.setAdapter(imageAdapter);
Button loadContent = (Button) findViewById(R.id.load_btn);
loadContent.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
if(load_images<count){
load_images++;
imageAdapter.LoadImage();
imagegrid.invalidateViews();
imagegrid.setAdapter(imageAdapter);
}
else{
Toast.makeText(getApplicationContext(), "Successfully load all the content. Subscribe to get more content.", Toast.LENGTH_SHORT).show();
}
}
});