I am trying to get a user input from a dialog prompt to determine wether a variable is true or false. I need to to do this before any other code in the List Activity class is executed.
Problem is no matter where I call the method that displays prompt, the rest of the code in the class continues to execute before the dialog returns a user choice!
Where is best place to place a dialog prompt, and stop code form executing until we get a response from the user via the dialog?
Thanks Ciaran
PS this is the code I call in the ListActovty onCreate method:
private void previewDives() {
//ask user if they wish to preview images in ist view as will take more time
AlertDialog.Builder build = null;
AlertDialog dialog = null;
build = new AlertDialog.Builder(this);
build.setCancelable(true);
build.setMessage("Do you want to preview your Dive Site images? \nThis may take more time if you have a large number of dives");
build.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// preview dives
preiwImagesInListView= true;
value++;
//return;//exit
}// end on click
});// end pos button take photo
// get photo from SD card option
build.setNegativeButton("No",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
preiwImagesInListView=false;
value++;
//return;//exit to oncreate
}// end onclick
});// end pos button take photo
dialog = build.create();
dialog.setTitle("Preview Dive Images");
dialog.show();
//return preiwImagesInListView;
}