android popupWindow

    private void showBillingPop() {


        Display dps=getWindowManager().getDefaultDisplay();
        final PopupWindow ppw= new PopupWindow(this);

        int width = dps.getWidth();
        int height = dps.getHeight();
        
        float w = (float) ((20.0/320.0)*width);
        float h = (float) ((120.0/480.0)*height);
        ppw.setWidth((int) (width-w));
        ppw.setHeight((int) (height-h));
        
        OnClickListener cl =new OnClickListener() {
            
            @Override
            public void onClick(View v ) {
                if(v.getId()==R.id.ct_dlg_yes){
                    SMS.checkFee("激活正版",
                            instance,
                            instance.smsl,  
                            "0111C0913311022193569711022193500101MC099888000000000000000000000000",//0811C1111411022172570111022172500101MC099694000000000000000000000000
                            "您将购买\"激活正版\",点击确定将会发送一条6元短信,不含信息费.",
                            "发送成功!已成功解锁!",true);
                }else{
                    Log.e(TAG, "----------------->>> ppw close <<<------------------");
                }
                
                ppw.dismiss();
            }
        };
        
        View v = LayoutInflater.from(mContext).inflate(R.layout.layout_ctdialog, null);
        
        TextView tv = (TextView) v.findViewById(R.id.ct_dialogtext);
        Button bty = (Button) v.findViewById(R.id.ct_dlg_yes);
        Button btn = (Button) v.findViewById(R.id.ct_dlg_no);
        ImageButton imbt=(ImageButton)v.findViewById(R.id.ct_dlg_close);

        tv.setText("仅需支付6元,即可享受正版游戏!感谢支持正版!");
        bty.setOnClickListener(cl);
        btn.setOnClickListener(cl);
        imbt.setOnClickListener(cl);
        
        ppw.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
        ppw.setContentView(v);
        ppw.setOutsideTouchable(false);
        ppw.setFocusable(true);
    
        ppw.update();
        ppw.showAsDropDown(v,(int)w/2,(int)h/2);
    }

你可能感兴趣的:(popup)