Android Custom Popupwindow considerations, phone and tablet differences

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.