Button add;
PopupWindow popupWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.popup);
// 팝업 윈도우를 출력하기 위한 버튼
add = (Button) findViewById(R.id.add);
add.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.add:
/* 윈도우 출력 */
break;
}
LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.sidemenu,
null);
popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
popupWindow.showAsDropDown(popupView, 80, 320);
Button btnexit = (Button) popupView
.findViewById(R.id.popup_close);
btnexit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
}
이 소스를 이용하여 팝업 윈도우를 띄웠습니다. 그런데
팝업을 띄우게 하는 버튼을 여러번 클릭하면
팝업이 여러번 뜨는거로 인식이 되는거 같습니다. 이것을 한번만 뜨게 하는 방법이 없을까요?