popuwindow使用

    /**
     * Created by renjianhong on 2016/3/24.
     */
    public class TaskPopuWindow extends PopupWindow {
        private View popuView;
        private TextView contentTv,locationTv,timeTv;

        public TaskPopuWindow(final Activity context) {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            popuView = inflater.inflate(R.layout.task_popu_window, null);
            contentTv = (TextView) popuView.findViewById(R.id.task_content);
            locationTv = (TextView) popuView.findViewById(R.id.task_location);
            if(!currentTaskContent.isEmpty()&&!currentTaskLocation.isEmpty()){
                contentTv.setText(currentTaskContent);
                locationTv.setText(currentTaskLocation);
            }

            timeTv = (TextView) popuView.findViewById(R.id.task_time);
//        int w = context.getWindowManager().getDefaultDisplay().getWidth();
            this.setContentView(popuView);
            // 设置SelectPicPopupWindow的View
            this.setContentView(popuView);
            // 设置SelectPicPopupWindow弹出窗体的宽
            this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
            // 设置SelectPicPopupWindow弹出窗体的高
            this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
            // 设置SelectPicPopupWindow弹出窗体可点击

        }

        /**
         * 显示popupWindow
         *
         * @param parent
         */
        public void showPopupWindow(View parent) {
            if (!this.isShowing()) {
                // 以下拉方式显示popupwindow
                Log.d("MainActivity","显示popupwindow方法被调用");
                this.showAsDropDown(parent,0,10);
            } else {
                this.dismiss();
            }
        }

}

 taskPopuWindow = new TaskPopuWindow(MainActivity.this);
 taskPopuWindow.showPopupWindow(waiterInfoLayout);

 waiterInfoLayout是你所希望的popuwindow在其下方显示的控件


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值