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

Advertise Here

Advertise Here

Advertise Here

Android Date Dialog Tutorial Using Basic4Android

KriXz

Tech Evangelist
K Rep
0
0
0
Rep
0
K Vouches
0
0
0
Vouches
0
Posts
113
Likes
48
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 100 XP
In my continuation on my first tutorial in using Dialogs, now I will introduce another kind of Dialog, the DateDialog.

First add the Dialog library as your references and create an abstract design. Next, put a button and named it Button1. Then saved the layout name "Main".

Here's the complete code for our tutorial.

  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. End

    Sub

  17. Sub

    Activity_Resume

  18. End

    Sub

  19. Sub

    Activity_Pause (UserClosed As

    Boolean

    )

  20. End

    Sub


  21. Sub

    Button1_Click
  22. Dim

    Dd As

    DateDialog
  23. Dd.Year = DateTime.GetYear(DateTime.Now)
  24. Dd.Month = DateTime.GetMonth(DateTime.Now)
  25. Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
  26. ret = Dd.Show("Set the required date"

    , "B4A Date Dialog"

    , "Yes"

    , "No"

    , "Maybe"

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

    & Dd.DayOfMonth & "/"

    & Dd.Month & "/"

    & Dd.Year , False

    )
  28. End

    Sub

Note:
Dd - used as our variable for our DateDialog.
Dd.Year = DateTime.GetYear(DateTime.Now) - syntax to get the year that is equivalent to the year now.
Dd.Month = DateTime.GetMonth(DateTime.Now) - syntax to get the month that is equivalent to the month now.
Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now) - syntax to get the day that is equivalent to what day is now.
ret - used as a variable for our return value.

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 the hidden content.
 

452,496

347,511

347,519

Top