I want to create an AlertDialog that will display a list of a custom object Supplier. The toString() method has been overridden to display a description.
AlertDialog.Builder dialog = new AlertDialog.Builder(ExampleActivity.this);
dialog.setTitle("Title");
dialog.setMessage("Message:");
final ArrayAdapter<Supplier> adapter = new ArrayAdapter<Supplier>(
ExampleActivity.this, android.R.layout.select_dialog_singlechoice);
adapter.add(new Supplier());
adapter.add(new Supplier());
adapter.add(new Supplier());
dialog.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
dialog.setNegativeButton("Cancel", null);
dialog.show();
From the examples I have looked at, I can't find anything obviously wrong with this code. However, when I run it, it doesn't show a list of the supplier objects as expected. I've also tried using the setItems and setSingleChoiceItems methods for the AlertDialog.Builder. Can anyone see where I am going wrong?