Android Simple Development Tutorial 17: Dialog Display images

Source: Internet
Author: User
Tags xmlns

Dialog generally refers to a small window that can be displayed in front of the activity, the current activity loses focus, and dialog accepts user input, which can typically be used to display messages or accept user input, and so on. It is generally not necessary to create an instance of the dialog class directly when using dialog. Instead, you can use Alertdialog,progressdialog,datepickerdialog,timepickerdialog. The most commonly used is alertdialog. The following is an example of using Alertdialog, using Alertdialog to select three examples of display images: Drawmap, jumbleimage,seethroughimage. The Drawmap is temporarily not covered, and will be followed by an introduction to the Internet Application display online map later.

Usually dialog is created as part of an activity, that is, in the Oncreatedialog (int) of the activity. When the dialog is created in Oncreatedialog (int), the Android system automatically manages the state of the dialog and takes the current activity as the owner of the dialog. And dialog also inherits some of the properties of the current activity, such as option Menu.

After you create the dialog, you can use ShowDialog (int) to display the dialog, and the ShowDialog parameter is the ID of the dialog. Before displaying Dialog, if you want to make changes to Dialog, you can add code to onpreparedialog (int, Dialog). Dismiss () Closes the dialog box. if DismissDialog (int) is used in the activity.

In this case, a button is used to trigger the dialog, res/layout in the Add Images.xml

<?xml version= "1.0″encoding=" utf-8″?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "Vertical"
android:background= "@drawable/white"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent" >
<com.pstreets.graphics2d.guidebeegraphics2dview
Android:id= "@+id/graphics2dview"
Android:layout_weight= "1″
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"/>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content"
android:orientation= "Horizontal"
>
<button android:text= "Images"
Android:id= "@+id/btnimages"
Android:layout_width= "Wrap_content"
Android:textcolor= "@color/black"
Android:checked= "true"
android:layout_height= "Wrap_content" >
</Button>
</LinearLayout>
</LinearLayout>

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.