My code goes inside an OnOptionsItemSelected method. I've tried displaying a simple toast and it works fine, so at least I know I'm "getting there".
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_multichoice);
adapter.add("whatever data1");
adapter.add("whatever data2");
adapter.add("whatever data3");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("whatever title");
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
}
});
The problem is that there's no alert dialog. I've tried constructing an alert dialog with simple arrays, which works.
You can use this adapter to provide views for an AdapterView , Returns a view for each object in a collection of data objects you provide, and can be used with list-based user interface widgets such as ListView or Spinner .
Android AlertDialog can be used to display the dialog message with OK and Cancel buttons. It can be used to interrupt and ask the user about his/her choice to continue or discontinue.
AlertDialog. A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout.
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
I think you are missing the
AlertDialog alert = builder.create();
alert.show();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With