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>