if you're already know the images path like "/mnt/sdcard/newphoto"!how to using AsyncTask load
images from that path and fill with listview,
Asked
Active
Viewed 1,936 times
-1

Goman
- 13
- 1
- 9
-
You cannot update your UI in your background thread – Rethinavel Nov 12 '13 at 07:42
-
have a look at this. Same question http://stackoverflow.com/questions/7729133/using-asynctask-to-load-images-in-listview – the-ginger-geek Nov 12 '13 at 07:43
-
you can retrieve the file from asyncTask however update the imageView in the `onPostExecute()` – Coderji Nov 12 '13 at 07:44
1 Answers
0
you can use this function in the AsyncTask<String><Void><Bitmap>
within doInBackground
:
ArrayList<String> f = new ArrayList<String>(); // list of available files in path
File[] listFile;
public void getSdcardImages()
{
File file= new File(android.os.Environment.getExternalStorageDirectory(),"MyFolder");
if (file.isDirectory())
{
listFile = file.listFiles();
for (int i = 0; i < listFile.length; i++)
{
f.add(listFile[i].getAbsolutePath());
}
}
}
then in onPostExecute(Bitmap b)
you can update the images

Coderji
- 7,655
- 5
- 37
- 51