1

ここに画像の説明を入力

ポップアップダイアログを表示するために実装した私のコードは次のとおりです

   public class ExPopup extends Activity {

Dialog myDialog;
Button myButton;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    AlertDialog.Builder helpBuilder = new AlertDialog.Builder(ExPopup.this);
    helpBuilder.setTitle("Pop Up");
    helpBuilder.setMessage("This is a Simple Pop Up 1");
    helpBuilder.setPositiveButton("Accept",
            new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // Do nothing but close the dialog
        }
    });

    helpBuilder.setNegativeButton("Decline", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Do nothing
        }
    });
    // Remember, create doesn't show the dialog
    final AlertDialog helpDialog = helpBuilder.create();
    WindowManager.LayoutParams wmlp = helpDialog.getWindow().getAttributes();
     wmlp.gravity = Gravity.TOP | Gravity.LEFT;
     wmlp.x = 70;   //x position
     wmlp.y = 70; 
    helpDialog.show();
    final Handler handler = new Handler();
    Timer tshow = new Timer();
    tshow.scheduleAtFixedRate(
            new TimerTask()
            {
                @Override
                public void run() {
                    handler.post(new Runnable() {
                        public void run() {
                            helpDialog.show();
                        }
                    });
                }
            },0,10000);
    final Handler handler1 = new Handler();
    Timer thide = new Timer();
    thide.scheduleAtFixedRate(
            new TimerTask()
            {
                @Override
                public void run() {
                    handler1.post(new Runnable() {
                        public void run() {
                            helpDialog.dismiss();
                        }
                    });
                }
            },0,20000);
    AlertDialog.Builder infoBuilder = new AlertDialog.Builder(ExPopup.this);
    infoBuilder.setTitle("Pop Up");
    infoBuilder.setMessage("This is a Simple Pop Up 2");
    infoBuilder.setPositiveButton("Accept",
            new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // Do nothing but close the dialog
        }
    });

    infoBuilder.setNegativeButton("Decline", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Do nothing
        }
    });

    // Remember, create doesn't show the dialog
    final AlertDialog infoDialog = infoBuilder.create();
    WindowManager.LayoutParams wmlp1 = helpDialog.getWindow().getAttributes();
     wmlp1.gravity = Gravity.TOP | Gravity.LEFT;
     wmlp1.x = -75;   //x position
     wmlp1.y = -25; 
    helpDialog.show();
    infoDialog.show();
    final Handler handler11 = new Handler();
    Timer tshow1 = new Timer();
    tshow1.scheduleAtFixedRate(
            new TimerTask()
            {
                @Override
                public void run() {
                    handler11.post(new Runnable() {
                        public void run() {
                            infoDialog.show();
                        }
                    });
                }
            },0,10000);
    final Handler handler12 = new Handler();
    Timer thide1 = new Timer();
    thide1.scheduleAtFixedRate(
            new TimerTask()
            {
                @Override
                public void run() {
                    handler12.post(new Runnable() {
                        public void run() {
                            infoDialog.dismiss();
                        }
                    });
                }
            },0,20000);
            }

             }

ここでは、上から時間に基づいてポップアップを追加しています。つまり、10 秒ごとに新しいポップアップが追加され、古いポップアップがダウンするので、2 から 3 のポップアップが追加され、古いポップアップがリストから消える必要があります ....だから助けてください私はこのシナリオであなたの助けをありがとう.....

4

1 に答える 1