Hi! The last time we had our tutorial is in the Color Dialog. Today i will introduce another kind of dialog that is similar in the Color Dialog in Android.
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:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Button1 As Button
Dim bmp As Bitmap
End Sub
I have initialized bmp as Bitmap because I wanted to have an icon to my ColorDialog. The difference of this Color Picker Dialog in the Color Dialog is that it can easily pick the color that you want and not to be able to adjust it.
Here's the full code for this tutorial:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Button1 As Button
Dim bmp As Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("Main")
bmp.InitializeSample(File.DirAssets, "bermoy.jpg",48,48)
Activity.Title = "Color Picker Dialog - Lyndon Bermoy"
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Dim cd As ColorPickerDialog
Dim color As Int
cd.RGB = Colors.DarkGray
ret = cd.Show("B4A ColorPicker Dialog", "Yes", "No", "Maybe", bmp)
ToastMessageShow(ret & " : " & cd.RGB, False)
Activity.color = cd.RGB
End Sub
Note:
cd - a variable used to initialized as an object of ColorPickerDialog.
color - the variable used as the color in terms of integer value.
cd.RGB = Colors.DarkGray - a syntax used in the default value of our RGB color that is in DarkGray.
ret - our variable in object that is used for the input dialog in color.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
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