First, the custom PPW is to inherit the Popupwindow
To successfully display the PPW of the definition, you must implement the following three lines of code
The three essential elements below, otherwise popwind not show up
This.setcontentview (MView);
This.setwidth (ViewGroup.LayoutParams.MATCH_PARENT);
This.setheight (ViewGroup.LayoutParams.MATCH_PARENT);
The above code must be set, otherwise the PPW will not show up.
This.setfocusable (TRUE);//causes the Popwind to not get the focus, the default is False, this is to make the EditText no focus, so the input box does not pop up
This.setbackgrounddrawable (New bitmapdrawable ());
This.setoutsidetouchable (TRUE); Click outside Popwind to close Popwind
I want to explain these two lines of code.
(1), setfocusable () This method is the same as the above explanation, but I would like to remind you that:
If your custom PPW contains the ListView control and set the Onitemclicklistener event,
because I encountered this problem in the project development, so put forward, this code on the phone side regardless of whether you set true or FALSE, the ListView Onitemclicklistener event will be triggered, However, setting the false in the Android tablet will not trigger the Onitemclicklistener event, so please note
(2), setoutsidetouchable () The description of this method is to click outside the PPW to close the PPW, but if you set this to true, then tell you that this does not play any role, Don't ask me why, because I don't know, if you want to work, you have to set this up . setbackgrounddrawable (New bitmapdrawable ());//This setting can be clicked on the outside of the screen dismiss window, the two lines of code used in order to play an effect
Android Custom Popupwindow considerations, phone and tablet differences