My cell phone Butler (19) Application Management Introduce yourself Popupwindow

Source: Internet
Author: User

My cell phone Butler (19) Application Management Introduce yourself Popupwindow

In the previous section, a pop-up window appears using the Click ListView to show our needs.

Popupwindow: A Popup window that can is used to the display an arbitrary view. The popup window is a floating container this appears on top of the current activity.

Popupwindow is a pop-up form that can display any view that is a floating container that appears above the current activity.

note To set a background for Popupwindow, otherwise, the Click Back key will appear and click the Popupwindow area outside, Popupwindow won't go away,

    Setting background: mpopupwindow.setbackgrounddrawable (new colordrawable ());

(1) button click to trigger Popupwindow display,

  Mpopupwindow.showasdropdown (Pview,60,-pview.getheight ());  Show the location of the Popupwindow

(2) When you click outside the Popupwindow area, Popupwindow disappears.

(3) Click the Popupwindow view option to perform the appropriate action.

 PackageCom.example.testpopmenu;ImportAndroid.app.ActionBar.LayoutParams;Importandroid.app.Activity;Importandroid.graphics.drawable.ColorDrawable;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;Importandroid.view.animation.AlphaAnimation;Importandroid.view.animation.Animation;ImportAndroid.view.animation.AnimationSet;Importandroid.view.animation.ScaleAnimation;ImportAndroid.widget.PopupWindow;ImportAndroid.widget.TextView;ImportAndroid.widget.Toast; Public classMainactivityextendsActivityImplementsOnclicklistener {Popupwindow Mpopupwindow;    View Popupview;    Animationset Animationset; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);    Setcontentview (R.layout.activity_main); }    /**     *      * @paramv*/     Public voidClick (View v) {Showpopupwindow (v); } @Override Public voidOnClick (View v) {if(mpopupwindow!=NULL) {Mpopupwindow.dismiss ();//disappear        }         Switch(V.getid ()) { CaseR.id.tv_lanuch://StartToast.maketext ( This, "Start", Toast.length_long). Show ();  Break;  CaseR.id.tv_uninstall://UninstallToast.maketext ( This, "System application requires root permission to uninstall", Toast.length_long). Show ();  Break;  CaseR.id.tv_share://ShareToast.maketext ( This, "Share", Toast.length_long). Show ();  Break; default:             Break; }    }        /*** pop-up window*/    protected voidShowpopupwindow (View pView) {if(mpopupwindow==NULL) {Popupview= View.inflate ( This, R.layout.popup_adapter,NULL); Mpopupwindow=NewPopupwindow (Popupview, Layoutparams.wrap_content,layoutparams.wrap_content,true); //set a background so that click the Back button can disappearMpopupwindow.setbackgrounddrawable (Newcolordrawable ()); TextView Tvstart=(TextView) Popupview.findviewbyid (R.id.tv_lanuch); TextView Tvuninstall=(TextView) Popupview.findviewbyid (R.id.tv_uninstall); TextView Tvshare=(TextView) Popupview.findviewbyid (R.id.tv_uninstall); Tvstart.setonclicklistener ( This); Tvuninstall.setonclicklistener ( This); Tvshare.setonclicklistener ( This); //Zoom AnimationScaleanimation a=NewScaleanimation (0, 1,0,1, Animation.relative_to_self,0.5f,animation.relative_to_self,0.5f                    ); A.setduration (200); //Gradient AnimationsAlphaanimation Alpha =NewAlphaanimation (0, 1); Alpha.setduration (200); Animationset=NewAnimationset (false);            Animationset.addanimation (a);                    Animationset.addanimation (Alpha); } mpopupwindow.showasdropdown (PView,60,-pview.getheight ());    Popupview.startanimation (Animationset); } }

My cell phone Butler (19) Application Management Introduce yourself Popupwindow

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.