Android 애플리케이션에서 사용자가지도에서 overlayItem을 1.5 초 이상 터치하면 AlertDialog가 표시됩니다. overlayItem을 유지하거나 맵에서 제거하려면 사용자의 대답 (alertDialogResult)이 필요합니다. 그러나 AlertDialog 내부 클래스가 호출 된 후 외부 클래스가 실행을 계속하고 그 시점에서 사용자의 대답이 없습니다.AlertDialog가 사용자의 응답을받을 때까지 외부 클래스 실행을 중지하는 방법은 무엇입니까?
제안 사항? AlertDialog에 대한 대안? 당신이 alertDialogResult 플래그를 필요로 할 이유
final Boolean alertDialogResult = false;
if ((pressEndTime - pressStartTime) > 1500) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mapView.getContext());
alertDialog.setTitle("Warning!");
alertDialog.setMessage("Do you want to delete the selected overlayItem?");
alertDialog.setCancelable(false);
alertDialog.setIcon(R.drawable.ic_dialog_alert);
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
alertDialogResult = true;
}
});
alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
alertDialog.show();
longPress = true;
if (alertDialogResult == true) {
AndroidMainActivity.sendDeleteOverlayRequest(mapView, overlayItemId);
}
IDE가 mapView와 OverlayItemId를 모두 final로 변경하도록 요청하고 있습니다. 의도하지 않은 결과가 있습니까? – fulupr
아니 .. 만약 당신이 그 변수를 변경하지 않으면 그것은 중요하지 않아야합니다. – nandeesh
글쎄, OnTouch가 실행될 때마다, overlayItemId가 변경됩니다 ... 그것은 당신이 참조하는 것입니까? – fulupr