I am using following code to create a Dialog aleart box with lists item from studentNames ArrayList.I am creating this ArrayList by reading childfile array.But when this code runs it just display a Dialog box with zero list item.I have even check my studentNames for null but it has values in it.According to documentation I need to set ListAdapter for showing list items in Dialog box , but that's also not working for me.Please help me finding the problem.
ArrayList<String> studentNames = new ArrayList<String>();
for (File file2 : childfile) {
studentNames.add(file2.getName());
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(student.getName()).setAdapter(new ArrayAdapter(context, android.R.layout.simple_list_item_1, studentNames),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch (which) {
cases
}
}
});
builder.create();
builder.show();