当我显示包含 Button 的 PopupWindow 时,我无法单击他。执行 onclick,但不更改图形。
它显示弹出窗口:
public void btn_friendsgame_newClick(View v) {
LayoutInflater layoutInflater =
(LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.custom_dialog, null);
RelativeLayout content = (RelativeLayout) popupView.findViewById(R.id.layout_content);
Button b = new Button(this); // THIS BUTTON CAN'T CLICK!
b.setText("Test");
b.setLayoutParams(new LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
content.addView(b);
final PopupWindow popupWindow = new PopupWindow(popupView,
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
popupWindow.showAtLocation(this.findViewById(R.id.main), Gravity.CENTER, 0, 0);
Button close = (Button) popupView.findViewById(R.id.btn_popup_settings);
close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
custom_dialog.xml:http ://pastebin.com/dLivuE17
如何修复这个?