Open “res/layout/main.xml” file, add time picker, label and button for demonstration.
File : res/layout/main.xml
P.S The “
TimePickerDialog” is declare in code, not XML.
2. Code Code
Read the code’s comment, it should be self-explanatory.
File : MyAndroidAppActivity.java
P.S The “TimePickerDialog” example above, is referenced from Google Android time picker example, with some minor change.
Run the application.
1. Result, “time picker” and “textview” are set to current time.
2. Click on the “Change Time” button, it will prompt a time picker component in a dialog box via
3. Both “time picker” and “textview” are updated with selected time.