Presentation is loading. Please wait.

Presentation is loading. Please wait.

Frank Xu Gannon University. A dialog is always created and displayed as a part of an Activity. You should normally create dialogs from within.

Similar presentations


Presentation on theme: "Frank Xu Gannon University. A dialog is always created and displayed as a part of an Activity. You should normally create dialogs from within."— Presentation transcript:

1 Frank Xu Gannon University

2

3

4

5

6

7 A dialog is always created and displayed as a part of an Activity. You should normally create dialogs from within your Activity's onCreateDialog(int) callback method. Activity onCreateDialog(int)

8 This is an Activity callback method that is passed the integer ID given to showDialog(int) (which is called by the button's View.OnClickListener ). When the ID matches the switch case defined here, a DatePickerDialog is instantiated with the DatePickerDialog.OnDateSetListener created in the previous step, along with the date variables to initialize the widget date Activity showDialog(int) View.OnClickListener DatePickerDialog DatePickerDialog.OnDateSetListener

9

10

11  Start a new project named HelloTimePicker.  Open the res/layout/main.xml file and insert the following:

12

13 When the user is done setting the time (clicks the "Set" button), the onTimeSet() method is called and it updates the member fields with the new time and updates the layout's TextView TextView

14

15

16  Copy the images on the right into the res/drawable/ directory of your project. These will be used for the different button states.  Create a new file in the res/drawable/ directory named android_button.xml. Insert the following XML: Note: The order of the elements is important. When this drawable is referenced, the s are traversed in-order to determine which one is appropriate for the current button state. Because the "normal" image is last, it is only applied when the conditions android:state_pressed and android:state _focused have both evaluated false. XML file that defines three different images to use for the different button states

17  Copy the images on the right into the res/drawable/ directory of your project. These will be used for the different button states.  Create a new file in the res/drawable/ directory named android_button.xml. Insert the following XML: This replaces the normal background image used for buttons throughout the system. In order for the drawable to change its image based on the button state, the image must be applied to the background. android_button.xml

18

19

20

21

22

23

24

25

26

27

28

29

30

31 -alternative to radio buttons

32

33

34

35

36

37

38


Download ppt "Frank Xu Gannon University. A dialog is always created and displayed as a part of an Activity. You should normally create dialogs from within."

Similar presentations


Ads by Google