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);
}
}