在Activity中使用popwindow不能使用不同的方法初始化popwindow中的控件
必须要使用:
contentView = LayoutInflater.from(this).inflate(R.layout.carepeople_add, null);
yes_bt = (Button) contentView.findViewById(R.id.add_ok_bt);
不然在对控件进行操作或监听时会报错
具体使用方法如下,
<span style="font-size:18px;"></span>
//添加界面popwindow控件
<span style="white-space:pre"> </span>contentView = LayoutInflater.from(this).inflate(R.layout.carepeople_add, null);
<span style="white-space:pre"> </span>mPopWindow = new PopupWindow(contentView,
<span style="white-space:pre"> </span>LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, true);
<span style="white-space:pre"> </span>phoneNumber_et = (EditText) contentView.findViewById(R.id.add_phoneNumber);
<span style="white-space:pre"> </span>city_et = (EditText) contentView.findViewById(R.id.add_city);
<span style="white-space:pre"> </span>message_et = (EditText) contentView.findViewById(R.id.add_message);
<span style="white-space:pre"> </span>yes_bt = (Button) contentView.findViewById(R.id.add_ok_bt);