I have a PopupWindow
on my activity. However, PopupWindow
is not dismissed after interacting with my activity.
I want to dismiss the popup when I'm touching/scrolling/clicking/etc on the screen which is not the PopupWindow
.
public class ListViewForDeleteContact extends AppCompatActivity {
ListView myListView;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.listviewfordeletecontactlayout_main);
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
LayoutInflater layoutInflater=(LayoutInflater)ListViewForDeleteContact.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dfg= layoutInflater.inflate(R.layout.popupwindowfordeletelayout_main,(ViewGroup)findViewById(R.id.popupId));
PopupWindow popupWindow=new PopupWindow(dfg,420,300,true);
popupWindow.showAtLocation(dfg, Gravity.CENTER, 0, 0);
popupWindow.setOutsideTouchable(true);
}
});
}
}
I tried some methods like setOutsideTouchable(true);
and setBackgroundDrawable(true)
but it did not work for me.