1

enter image description here

Here is my code i implemented to show the popup dialog

   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);
            }

             }

Here from above iam adding a popup based on time i mean for every 10 sec new popup is added and the old popup will come down so up on 2 to 3 added and old popups must be disappeared from the list ....So please help me in this scenario Thank you for your help .....

4

1 回答 1

0

你走在正确的轨道上:

  1. 绘制线性或相对的四个布局。
  2. 将背景设置为透明
  3. 使 popup2 到 popup4 不可见。
  4. 每 10 分钟调用一次线程,并将相对布局的线性设置为可见。
  5. 使用样式显示弹出动画。
  6. 运行,您将在每 10 秒后弹出一个
于 2013-05-12T20:48:59.083 回答