English 中文(简体)
如何制止外部处决,直到警觉组织得到用户的反应?
原标题:How to stop outer-class execution until AlertDialog get user s response?

在我的安乐斯应用中,当用户在地图上播放超过1.5秒的警示。 我需要用户回答(alertDialogRes),以保持超支。 项目或将其从地图上删除。 然而,在接到警报后,外部阶级继续处决,当时我没有用户回答。

任何建议? 警惕性运动的任何替代办法?

    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);
            }
最佳回答

为什么需要警惕 牙齿

  AndroidMainActivity.sendDeleteOverlayRequest(mapView, overlayItemId); 

to onClick of positiveButton

<<>Edit>/strong>:您的警惕性格在开始使用后不会等待用户的参与。 因此,奥恩卡克被击退。

问题回答

Put
AndroidMainActivity.sendDeleteOverlayRequest(mapView, overlayItemId);
in the onClick of the positiveButton.
This way only you can achieve what you are asking, ie. perform the action after the user input.





相关问题
How to access outer class from an inner class?

I have a situation like so... class Outer(object): def some_method(self): # do something class Inner(object): def __init__(self): self.Outer.some_method() # &...

Do java s Inner classes pose a security risk?

Recently the security team on my project released a secure code guidelines document, designed to be used as part of our code reviews. The first thing that struck me was an item that said "Do not use ...

Inner class in interface vs in class

What is the difference between these two innerclass declarations? Also comment on advantages/disadvantages? case A: class within a class. public class Levels { static public class Items { ...

How many times can classes be nested within a class?

I came across this questions on one of the online Java Tests. The options were 4,5,8 and any number of times. I have only used one inner class, but have never tried multiple ones. I was wondering if ...

Nested classes scope?

I m trying to understand scope in nested classes in Python. Here is my example code: class OuterClass: outer_var = 1 class InnerClass: inner_var = outer_var The creation of class ...

热门标签