//弹框
//点击条目把值传过去 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); } });