Android Beginner 2016 (13)--Blocking dialog box Popupwindow

Source: Internet
Author: User

The last two chapters have said a non-blocking dialog, today talk about the blocked dialog box--popupwindow

So what is blocking what is non-blocking? What's the difference between Popupwindow and alertdialog?

First say Alertdialog, pop-up, the back will be gray, and there is no blocking the background of the process, if there is no special control, click Behind the Gray, the box will disappear.

As for Popupwindow, it is bounce out, there is no change in the back, and blocking the application process, if not quit, the application sink has been waiting, click on the back is not responding.

Do not know why now can not upload pictures, do not upload, in fact, as Alertdialog.

or continue to use the previous code to augment

To see how this can be achieved:

Added a popup_window.xml

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" wrap_content "android:orientation=" vertic Al "android:background=" #FFFFFF "> <textview android:id=" @+id/data_view "android:layout_height=" W Rap_content "android:text=" I want Big Health "android:layout_width=" Fill_parent "/> <edittext android: Id= "@+id/data_edit" android:layout_height= "wrap_content" android:layout_width= "fill_parent"/> &L T LinearLayout android:id= "@+id/linearlayout01" android:layout_height= "wrap_content" android:layout_width= "Fill_par ENT "android:gravity=" center "> <button android:layout_width=" wrap_content "android:layout_height=" Wra P_content "android:id=" @+id/btnok "android:layout_weight=" android:text= "OK" > </butto N> <button Android:laYout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_weight= "Android"   : text= "Cancel" android:id= "@+id/btncancel" > </Button></LinearLayout> </LinearLayout>
Declares a caption, a dialog box, and two buttons.

Then see the implementation code, see the Alertdialog can be transferred to the following code to go.

Package Com.fable.helloworld;  Import android.app.Activity; Import Android.app.alertdialog;import Android.content.context;import Android.content.dialoginterface;import Android.content.res.resources;import Android.graphics.color;import Android.graphics.drawable.drawable;import   Android.os.Bundle; Import Android.view.gravity;import Android.view.layoutinflater;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.adapterview;import Android.widget.adapterview.onitemclicklistener;import Android.widget.button;import Android.widget.EditText; Import Android.widget.gridview;import Android.widget.popupwindow;import android.widget.SimpleAdapter; Import java.util.*;p ublic class Helloworldactivity extends Activity {@Override public void onCreate (Bundle save        Dinstancestate) {super.oncreate (savedinstancestate);  Setcontentview (R.layout.activity_hello_world);          Set main layout file GridView GridView = (GridView) Findviewbyid (R.id.gridview);        Create data source arraylist

To facilitate comparison, this time the code retains the first two chapters,

Non-blocking dialog box Alertdialog and layout file-based Alertdialog

Add up a bit more. So uploaded the code, and so on through the audit post link.



Android Beginner 2016 (13)--Blocking dialog box 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.