popupWindow弹框

来源:互联网 发布:韩火火的淘宝店 编辑:程序博客网 时间:2024/06/06 16:25

//弹框

//点击条目把值传过去holder.itemView.setOnClickListener(new View.OnClickListener() {    public void onClick(View v) {        //把点击的position传过去        mInfo.dianji(position);        //popupwindow弹框        LinearLayout layout = new LinearLayout(mContext);        layout.setBackgroundColor(Color.GRAY);        TextView tv = new TextView(mContext);        tv.setLayoutParams(new GridLayoutManager.LayoutParams(GridLayoutManager.LayoutParams.WRAP_CONTENT, GridLayoutManager.LayoutParams.WRAP_CONTENT));        tv.setText(mList.get(position).getName());        tv.setTextColor(Color.WHITE);        layout.addView(tv);        PopupWindow popupWindow = new PopupWindow(layout,50,60);        popupWindow.setFocusable(true);        popupWindow.setOutsideTouchable(true);        popupWindow.setBackgroundDrawable(new BitmapDrawable());        int[] location = new int[2];        v.getLocationOnScreen(location);        //在这里可以设置弹框的位置        popupWindow.showAsDropDown(v,200,-100);    }});

1 0
原创粉丝点击