대화 상자 프롬프트에서 사용자 입력을 얻어 변수가 참인지 거짓인지 판단하려고합니다. List Activity 클래스의 다른 코드가 실행되기 전에이 작업을 수행해야합니다.나머지 코드를 실행하기 전에 대화 상자에서 사용자 입력 받기
문제는 내가 프롬프트를 표시하는 메서드를 호출해도 문제가되지 않습니다. 대화 상자가 사용자 선택을 반환하기 전에 클래스의 나머지 코드가 계속 실행됩니다.
대화 상자 프롬프트를 배치하고 대화 상자를 통해 사용자로부터 응답을받을 때까지 코드 양식 실행을 중지하는 가장 좋은 장소는 어디입니까?
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;
}
감사합니다. 대화 상자가 diff 스레드에서 실행되었음을 인식하지 못했습니다 ... – dancingbush