ALTERNATIVE OPTION
This is my first post so I'm excited to share my code!
This worked for me:
Place these two lines above the OnCreate event
final String[] Options = {"Red", "Blue"};
AlertDialog.Builder window;
Place this code on the event that will trigger this
window = new AlertDialog.Builder(this);
window.setTitle("Pick a color");
window.setItems(Options, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(which == 0){
//first option clicked, do this...
}else if(which == 1){
//second option clicked, do this...
}else{
//theres an error in what was selected
Toast.makeText(getApplicationContext(), "Hmmm I messed up. I detected that you clicked on : " + which + "?", Toast.LENGTH_LONG).show();
}
}
});
window.show();