0

In my android application when i clicked a button it shows a popup box but i can't able to dismiss that box by clicking the same button or any else outside the popup box. Here i enclosed my android code for popup function.I tried by adding

m_pw.dismiss();

function but it's too failed.

popup.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v){
            LayoutInflater inflater =(LayoutInflater) ChooseFileActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.saved,null);
            m_pw = new PopupWindow(layout, 400, 300, true);
            popup(v, layout);
        }


    });

public void popup(View v, View layout){
    if (m_pw.isShowing()) {
        m_pw.dismiss();
    } else {
        m_pw.showAtLocation(layout, Gravity.TOP, -80, 80);


    }
}
BobDroid
  • 1,898
  • 5
  • 19
  • 39

1 Answers1

0

This is because the popup window does not respond to onTouch or onKey events unless it has a background that != null.

Check the below links for further clarifiactaion:

Android popup window dismissal

Community
  • 1
  • 1
Deva
  • 3,919
  • 1
  • 27
  • 38