創建一個popUpWindow

    /**
     * 購物車對話框
     */
    private void showPoppupWindow() {
        View cart_data_view = LayoutInflater.from(HDJHomePageActivity.this).inflate(R.layout.hdj_vege_fruits_pop, null);
        pop_listview = (ListView) cart_data_view.findViewById(R.id.hdj_vf_pop_view);
        ImageView canclePop = (ImageView) cart_data_view.findViewById(R.id.hdj_gouwuche_cancle);
        okPop = (TextView) cart_data_view.findViewById(R.id.hdj_gouwuche_ok);
        priceSumTxt = (TextView) cart_data_view.findViewById(R.id.hdj_gouwuche_priceSum);
        pop_listview.setSelector(new ColorDrawable(Color.TRANSPARENT));
        xianshiChae();
        popListviewAdapter = new HDJCartPopListviewAdapter(HDJHomePageActivity.this, HDJHomePageActivity.this);
        pop_listview.setAdapter(popListviewAdapter);
        String priceNum = String.format(getResources().getString(com.jminhui.cshop.R.string.product_price), Float.valueOf(""+gouwuCheZongjia()));
        priceSumTxt.setText(""+String.valueOf(priceNum));
        popListviewAdapter.setData(mProducts);
//        fujinAdapter = new NSPopFujinListviewAdapter(HDJVegetableFruitActivity.this);
//        pop_listview.setAdapter(fujinAdapter);
//        fujinAdapter.setList(near);
//        int height=  this.getWindowManager().getDefaultDisplay().getHeight();
//        popupWindow = new PopupWindow(cart_data_view, LinearLayout.LayoutParams.MATCH_PARENT, height*6/10, true);
        popupWindow = new PopupWindow(cart_data_view, LinearLayout.LayoutParams.MATCH_PARENT,  LinearLayout.LayoutParams.WRAP_CONTENT, true);

        popupWindow.setTouchable(true);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
        //設置SelectPicPopupWindow彈出窗體的背景
        ColorDrawable dw = new ColorDrawable(Color.WHITE);
        popupWindow.setBackgroundDrawable(dw);
//        popupWindow.showAsDropDown(fujin, 0, 0);
        popupWindow.showAtLocation(HDJHomePageActivity.this.findViewById(R.id.hdj_home_rela), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
        //設置背景顏色變暗
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.alpha = 0.7f;
        getWindow().setAttributes(lp);
        countItemHight();
        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                WindowManager.LayoutParams lp = getWindow().getAttributes();
                lp.alpha = 1f;
                getWindow().setAttributes(lp);
//                fujin_icon.setImageDrawable(getResources().getDrawable(R.drawable.ns_icon_jiantou_down));
            }
        });
        canclePop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popupWindow.dismiss();
            }
        });
        okPop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(gouwuCheZongjia()>=Double.parseDouble(homeModel.getStart_price())) {
                    ArrayList<String> productIds = new ArrayList<String>();
                    ArrayList<String> productNums = new ArrayList<String>();
                    ArrayList<String> productPrice = new ArrayList<String>();
                    ArrayList<String> productName = new ArrayList<String>();
                    for (int i = 0; i < mProducts.size(); i++) {
                        productIds.add(mProducts.get(i).getId());
                        productNums.add(mProducts.get(i).getNumber() + "");
                        productPrice.add(mProducts.get(i).getGood_price());
                        productName.add(mProducts.get(i).getGood_name());
                    }
                    Intent intent = new Intent(HDJHomePageActivity.this, OSPCommitOrderActivity_.class);
                    intent.putStringArrayListExtra("productIds", productIds);
                    intent.putStringArrayListExtra("productNums", productNums);
                    intent.putStringArrayListExtra("productPrice", productPrice);
                    intent.putStringArrayListExtra("productName", productName);

                    intent.putExtra("market_id", mProducts.get(0).getMarket_id());
                    intent.putExtra("market_name", shopName);
                    intent.putExtra("info", new OSPShopCartInfo.InfoBean());
                    startActivity(intent);
                }
            }
        });
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章