Android Number Dialog Tutorial using Basic4Android

Hi! Another tutorial for working with Dialogs is this what we called Number Dialog. This Dialog only refers to inputting of numbers either decimal, integer, or any numbers 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 Color HSV Dialog. Here's the full code for this 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.  
  5. End Sub
  6.  
  7. Sub Globals
  8.         'These global variables will be redeclared each time the activity is created.
  9.         'These variables can only be accessed from this module.
  10.  
  11.         Dim Button1 As Button
  12.         Dim bmp As Bitmap
  13. End Sub
  14.  
  15. Sub Activity_Create(FirstTime As Boolean)
  16.         'Do not forget to load the layout file created with the visual designer. For example:
  17.         'Activity.LoadLayout("Layout1")
  18.         Activity.LoadLayout("Main")
  19.         bmp.InitializeSample(File.DirAssets, "bermoy.jpg",48,48)
  20.         Activity.Title = "Number Dialog - Lyndon Bermoy"
  21.        
  22. End Sub
  23.  
  24. Sub Activity_Resume
  25.  
  26. End Sub
  27.  
  28. Sub Activity_Pause (UserClosed As Boolean)
  29.  
  30. End Sub
  31.  
  32. Sub Button1_Click
  33.         Dim nd As NumberDialog
  34.         nd.Digits = 10
  35.         nd.Number = -12345
  36.         nd.Decimal = 2
  37.         nd.ShowSign = True
  38.         ret = nd.Show("B4A Number Dialog", "Yes", "No", "Maybe", bmp)  
  39.         ToastMessageShow(ret & " : " & nd.Number, False)       
  40. End Sub
Note: nd - our variable used for initiating NumberDialog. nd.Digits = 10 - the number of digits that we initialized is at 10 digits. nd.Decimal = 2 - a syntax used in the declaring the number of decimal places, but we initialized it in two decimal places. nd.ShowSign = True - a syntax used in declaring and showing the sign of the numbers either positive or negative. ret - our variable in object that is used for the input dialog in color. 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

Comments

Hello my friend Thanks for nice source Numbers between 1 and 9 How can I take the numbers from 1 to 100 Thank you

Add new comment