Android Color Hue Saturation Value Dialog using Basic4Android
Submitted by donbermoy on Wednesday, January 22, 2014 - 16:11.
Another tutorial for Color Dialog is this what we called Color Hue and Saturation Value Dialog. This Color HSV Dialog is different from the typical Color Dialog because it only has RGB Color. But this one uses the Hue and Saturation Values of the Color 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:
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:
Note:
cd - our variable used for initiating ColorDialogHSV for Hue and Saturation values.
color - the variable used as the color in terms of integer value.
cd.Hue = 180 - a syntax used in the default value of our Hue Color is at 180.
cd.Saturation = 0.5 - a syntax used in the default value of our Saturation Color is at 0.5.
cd.Value = 0.5 - a syntax used in the default value of our Saturation Color is at 0.5.
ret - our variable in object that is used for the input dialog in color.
Activity.color = cd.RGB - a syntax in which when you chose the color for HSV and then clicked it, the background of the activity will also changed in corresponds to the value of HSV 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
- 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 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 Dialog HSV - Lyndon Bermoy"
- End Sub
- Sub Activity_Resume
- End Sub
- Sub Activity_Pause (UserClosed As Boolean)
- End Sub
- Sub Button1_Click
- Dim cd As ColorDialogHSV
- Dim color As Int
- cd.Hue = 180
- cd.Saturation = 0.5
- cd.Value = 0.5
- ret = cd.Show("B4A Color HSV Dialog HSV", "Yes", "No", "Maybe", bmp)
- ToastMessageShow(ret & " : " & cd.RGB, False)
- Activity.color = cd.RGB
- End Sub
Add new comment
- 61 views