Android Popupwindow pop-up window (with common sharing interface as an example)

Source: Internet
Author: User

1. Main code:

Statement:

Private View shareview;private Popupwindow pop;

In the OnCreate method:

introduced window profile Shareview = Layoutinflater.from (this). Inflate (r.layout.jyx_activity_share, NULL);//Create Popupwindow Object pop = New Popupwindow (Shareview, layoutparams.match_parent,layoutparams.wrap_content, false);//need to set this parameter, Click outside to disappear pop.setbackgrounddrawable (new colordrawable ());//Set the window to the outside window disappears pop.setoutsidetouchable (true); Pop.setanimationstyle (R.style.animationpreview);//Set this parameter to get focus, otherwise you cannot click Pop.setfocusable (TRUE); Pop.setondismisslistener (New Ondismisslistener () {@Overridepublic void Ondismiss () {SHARESDK.STOPSDK ( productactivity.this);});

In the onclick event: (one is a shared button, one is the Cancel button in the box)

Case R.id.share:if (Pop! = null &&!pop.isshowing ()) {pop.showatlocation (View.getrootview (), Gravity.bottom, 0, 0);} Break;case r.id.btn_cancel:if (Pop! = null && pop.isshowing ()) {Pop.dismiss ();} Break

Effect:




Android Popupwindow pop-up window (with common sharing interface as an example)

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.