Popwindow的使用

Popwindow的使用

关联第三方popwindow库
使用popwindow

关联第三方popwindow库

    compile 'com.github.pinguo-zhouwei:CustomPopwindow:2.0.0'

使用popwindow

   View contentView = AppUtils.inflate(R.layout.alertdialog_talklocation);
            PopupWindow mPopWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
            ImageView locationClose = (ImageView) contentView.findViewById(R.id.logistics_info_close);
            EditText locationRemark = (EditText) contentView.findViewById(R.id.dialog_talklocation_remark);
            TextView locationBtn = (TextView) contentView.findViewById(R.id.dialog_talklocation_btn);
            locationClose.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mPopWindow.dismiss();
                }
            });
            locationBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    sRemark = locationRemark.getText().toString();
                    initLocation();
                    startLocation();
                    mPopWindow.dismiss();
                }
            });
            mPopWindow.setContentView(contentView);
            mPopWindow.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0);
        }

你可能感兴趣的:(Android)