I have an AlertDialog setup almost identical to the one described in this link: https://stackoverflow.com/a/4697761/2593088
I use it for pulling photos from an SD card, so i have the photo and the name next to it in the list. It works great if I only need to pull one photo at a time, but it would be nicer if I could just select all the photos and pull them over all at once. The problem is as soon as one is clicked the dialog closes. I have searched ways around this but each way I've found doesn't work for what I need. One way was to overwrite the onClick listener in the dialogs OnShow listener but I could only figure how to overwrite the positive/negative/neutral buttons, not the list items. I have also been able to make it work without the icons using the setMultiChoiceItems when building the dialog, so if there is a simple way to just add icons at this point that would work too. I'm just wondering if there is a simple way to do it with what I have or if I have to write my own customer adapter or somthing.
Any help is Appreciated.
EDIT: here is what i have that works fine except there are no icons.
dialog = builder.setAdapter(adapter, null).setMultiChoiceItems(mFileList, null, new OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1,
boolean arg2) {
String selectedFile = mFileList[arg1];
if(selectedFile.equals("Up One Folder")) selectedFile = "..";
String mChosenFile = tempDir + "/" + selectedFile;
File f = new File(mChosenFile);
if(f.isDirectory()) {
// it is a directory, clear all selections and go to the next directory
selectedImages.clear();
dialog.dismiss();
loadFileList(mChosenFile);
getFiles(false);
} else {
if(arg2) {
selectedImages.add(tempDir + "/" + selectedFile);
}
}
}
})
I was hoping that using both setAdapter and setMultiChoiceItems would work but setting the adapter does nothing if the multichoice items is set. And unfotunately setMultiChoiceItems doesn't have a constructor that uses an adapter.