如果我的PopupWindow引入的View通过inflate加入,而且里面有个按钮用来关闭次popupWindow 需要做如下设置
public void onClick(View v) {
LayoutInflater inflater = (LayoutInflater)
roomate.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popupView=inflater.inflate(R.layout.popup, null, false);
pw = new PopupWindow(popupView, 300, 300, true);
pw.showAtLocation(roomate.findViewById(R.id.tbC), Gravity.CENTER, 0, 0);
ImageButton imbClosePopUp=(ImageButton)popupView.findViewById(R.id.imbClosePopUp);
imbClosePopUp.setOnClickListener(ClosePopUp);
}
也就说呢findViewById要根据情况使用,看看是属于那个view的