I want to create an AlertDialog that displays a list of a custom Supplier object. 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 looked at, I cannot find anything obviously wrong with this code. However, when I run it, it does not display the list of provider objects as expected. I also tried using the setItems and setSingleChoiceItems for AlertDialog.Builder . Can anyone see where I'm wrong?
source share