• We just launched and are currently in beta. Join us as we build and grow the community.

Android Time Dialog Tutorial using Basic4Android

Logic12345

Organic Reach Hacker
L Rep
0
0
0
Rep
0
L Vouches
0
0
0
Vouches
0
Posts
132
Likes
166
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Hi! this is my 3rd tutorial on using the Dialogs in B4A. I will introduce another kind of dialog, the Time Dialog.

First, you need to create one button and named it Button1. Next, named your layout name as "Main".

Declare first your variable in the Sub_Global like this:

  1. Sub

    Globals
  2. 'These global variables will be redeclared each time the activity is created.
  3. 'These variables can only be accessed from this module.

  4. Dim

    Button1 As

    Button
  5. Dim

    bmp As

    Bitmap
  6. End

    Sub

I have initialized bmp as Bitmap because I wanted to have an icon to my TimeDialog.

Here's the full code for this:

  1. Sub

    Process_Globals
  2. 'These global variables will be declared once when the application starts.
  3. 'These variables can be accessed from all modules.

  4. End

    Sub

  5. Sub

    Globals
  6. 'These global variables will be redeclared each time the activity is created.
  7. 'These variables can only be accessed from this module.

  8. Dim

    Button1 As

    Button
  9. Dim

    bmp As

    Bitmap
  10. End

    Sub

  11. Sub

    Activity_Create(FirstTime As

    Boolean

    )
  12. 'Do not forget to load the layout file created with the visual designer. For example:
  13. 'Activity.LoadLayout("Layout1")
  14. Activity.LoadLayout("Main"

    )
  15. bmp.InitializeSample(File.DirAssets, "bermoy.jpg"

    ,48,48)
  16. Activity.Title = "Time Dialog - Lyndon Bermoy"

  17. End

    Sub

  18. Sub

    Activity_Resume

  19. End

    Sub

  20. Sub

    Activity_Pause (UserClosed As

    Boolean

    )

  21. End

    Sub

  22. Sub

    Button1_Click
  23. Dim

    td As

    TimeDialog
  24. Dim

    txt As

    String
  25. Dim

    ret As

    Object
  26. td.Hour = DateTime.GetHour(DateTime.Now)
  27. td.Minute = DateTime.GetMinute(DateTime.Now)
  28. td.Is24Hours = True
  29. ret = td.Show("Set the required time"

    , "B4A Time Dialog"

    , "Yes"

    , "No"

    , "Maybe"

    , bmp)
  30. ToastMessageShow(ret & " : "

    & td.Hour & ":"

    & td.Minute, False

    )
  31. End

    Sub

Note:
td - used as my variable for TimeDialog
txt - used as my variable for String
ret - used as my variable for Object
td.Hour = DateTime.GetHour(DateTime.Now) - my syntax used to get the hour at this moment.
td.Minute = DateTime.GetMinute(DateTime.Now) - my syntax used to get the minute at this moment.
td.Is24Hours = True - syntax used to determine if you want to configure the time in 24hours.

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]

Add and Follow me on Facebook: https://www.facebook.com/donzzsky

Visit and like my page on Facebook at: https://www.facebook.com/BermzISware


Download
You must upgrade your account or reply in the thread to view hidden text.
 

449,193

322,229

322,238

Top