PopupWindows SetOnDismiss never called

This is my implementation for the dissmiss event and when my popupWindows is dismissed or disposed because the user touched outside my DisposeManager.Dismissed is never called.

Code: http://pastebin.com/TAHQrLRS

Also is there a way not to close the popupWindow when user touch outside of its boundary, I tryed with popup.OutsideTouchable = false; but the end result was the same ?!


  • CortezCortez USMember ✭✭✭

    Hello @DimitarIvanov !

    Try to use the AlertDialog. For me it's defaultly no closing the dialog.

  • DimitarIvanovDimitarIvanov USMember ✭✭

    Ok with the DismissEvent I was able to get notifyed but according to google and Xamarin documentation when PopupWindow property OutsideTouchable is set to false it doesn't get notified for the touch event outside the scope of the popup.

    I want this popup to dismiss only when I call the dismiss method,is it possible ?

  • DimitarIvanovDimitarIvanov USMember ✭✭

    @Cortez Thanks for your answer man but the popup is doing it's job I have to change alot in order to make it work with AlertDialog.
    I was thinking even if it's not possible to make what I want I can always check if user selected something from that popup and if not just show it on screen again.

  • CortezCortez USMember ✭✭✭

    Hello @DimitarIvanov !

    I created a very simple example and the dialog doesn't dismiss when i touch the background layout. First and for all you don't need to implement the IOnDismissListener interface. Just

    popup.DismissEvent += (sender, e) => { };

    I created this:


    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:id="@+id/myButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout>


    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/llPop" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/holo_blue_bright"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text = "Text"/> </LinearLayout>


    [Activity (Label = "PopupWindowsDismiss", MainLauncher = true, Icon = "@drawable/icon")] public class MainActivity : Activity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Main); Button button = FindViewById<Button> (Resource.Id.myButton); button.Click += delegate { LayoutInflater inflater = (LayoutInflater) GetSystemService(LayoutInflaterService); PopupWindow pop = new PopupWindow(inflater.Inflate(Resource.Layout.Popup, null, false), 200, 200,true); pop.ShowAtLocation(FindViewById(Resource.Id.myButton),GravityFlags.Center, 0, 0); }; } }

  • DimitarIvanovDimitarIvanov USMember ✭✭

    Well now it is working but the listView inside it can't detect touch event because the popupWindows background is null,and when I set it the same problem apper the popup again dispose when the user touch outside of the popup area

Sign In or Register to comment.