B4J Question Classes - How to use a custom view

saunwin

Active Member
Licensed User
Longtime User
Good afternoon,
Forgive a total newbie, but I've been hunting around all day trying to find out how to use a custom view. I want to use a colorpicker class which I downloaded, unzipped, added to my project, etc. This has given me another form with the custom view on it. How do I use the new custom form in my (main) form ? Is there a how to somewhere ? TIA
 

MarkusR

Well-Known Member
Licensed User
Longtime User
a typical custom view appear in designer at menu add view / custom view / color picker.
did you see something there if you open the designer for your main layout?
 
Upvote 0

saunwin

Active Member
Licensed User
Longtime User
Thanks for the reply Markus, Customview is greyed out - so I guess i havn't done something right ?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Depending on what B4J version or the way it was implemented, your custom view may or may not have Visual Designer support.
In the first case, you need to add it by code, but if it has designer support, then it will show in the designer views list Under customview.
The fact that you say it's grayed out, to me it says it has been used (in the custom view demo maybe), but has not been Added to the current project.
Make sure you have selected the CustomView in your libs tab.
 
Upvote 0

saunwin

Active Member
Licensed User
Longtime User
Thanks cableguy. The customview (colorpalette) doesn't appear in the library list. I have set the path and unpacked the files into that folder, added the files to the project, but customview is still greyed out ;(
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You are still not providing any useful informations for us to help you.
What exactly is the customview? URL
Where is your testproject which shows the problem?
 
Upvote 0

saunwin

Active Member
Licensed User
Longtime User
OK I think I've done that correctly.
Please see attached
 

Attachments

  • test_project.zip
    85.5 KB · Views: 189
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
ColorPalette is a Class which you need to declare and use in your Activity. It is NOT a CustomView.

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("PC_app") 'Load the layout file.
    MainForm.Show
   
    Dim colpal As ColorPalette
    colpal.Initialize(Me,"Main","mycol")
    colpal.GetColor
End Sub
Sub mycol_Result(selectedcolor As Paint,success As Boolean)
    Log($"mycol_Result(${selectedcolor}, ${success})"$)
End Sub
mycol_Result(0x2448daff, true)
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
LOOOOOL!!!!!

You are member since 2011.

Even a mechanical engineer that never used a paintbrush, but learks at painting forums for years, will be a newbie if he doesn't get his hands dirty!
B4J was out for about 2 years before I decided to give it a go… It's been about 4 years that I have not touched much of android, so Iwill have newbie questions once I return to it...
 
Upvote 0
Top