An example of this article describes the Android pop-up window implementation method. Share to everyone for your reference, specific as follows:
Directly on the code:
/**
* Window--Beginner's Guide
* @param cxt
* @param ID Resource number
* @create_time 2011-7-27 PM 05:12:49
* * Public static void Displaywindow (context cxt, int id) {
final TextView Imgtv = new TextView (Cxt.getapplicationcontext ());
imgtv.setbackgrounddrawable (Cxt.getresources (). getdrawable (ID));/Set Background
final WindowManager wm = ( WindowManager) Cxt.getapplicationcontext (). Getsystemservice ("window");
Windowmanager.layoutparams wmparams = new Windowmanager.layoutparams ();
Wmparams.type = 2002;
Wmparams.format = 1;
Wmparams.flags = n;
Wmparams.width = layoutparams.fill_parent;
Wmparams.height = layoutparams.fill_parent;
Wm.addview (IMGTV, wmparams);
Imgtv.setonclicklistener (New Button.onclicklistener () {
@Override public
void OnClick (View v) {
Wm.removeview (IMGTV);//Click, Fade the Window
}}
);
Don't forget to add permissions to the Androidmanifest.xml:
Copy Code code as follows:
<uses-permission android:name= "Android.permission.SYSTEM_ALERT_WINDOW"/>
Android.permission.SYSTEM_ALERT_WINDOW
Allows a program to open windows using Type_system_alert, displayed at the top of all other programs (allows an application to open windows using the TYPE Type_system_alert, shown On top of all other applications. )
The value of this First_system_window is 2000. The difference between 2003 and 2002 is that the 2003 type view is higher than the 2002 type, and can be displayed on the System dropdown status bar!
I hope this article will help you with the Android program.