大家好,我正在尝试将自定义弹出窗口放入布局弹出窗口中正确显示。如果按下按钮一次,然后单击关闭或外部区域,它会正确关闭,但是当按钮按下两次时,弹出窗口并非全部关闭。任何人都可以建议我下面的代码。
popupView = getLayoutInflater().inflate(R.layout.word_meaning, null, false);
popupWindow = new PopupWindow(
popupView,
100,
100, true);
dismiss = (Button)popupView.findViewById(R.id.dismiss);
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
// Removes default black background
popupWindow.setBackgroundDrawable(new BitmapDrawable());
dismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) { System.out.println("dismiss");
// TODO Auto-generated method stub
popupView.setVisibility(View.GONE);
popupWindow.dismiss();
//System.out.println("View"+popupView.getVisibility());
}});
popupView.setVisibility(View.VISIBLE);
rel_layout.addView(popupView);