B4J Question First Example with GPT B4X BUILDER (Custom ListView)

ivanomonti

Expert
Licensed User
Longtime User
👋 I'm sharing an early example of a Custom ListView fully generated by GPT – B4X BUILDER, my personalized AI assistant for B4J/B4X development.

The code is already functional and produces good results, even though there’s still room for improvement in how it handles some JavaFX components.
The goal is to demonstrate how useful a GPT can be when generating actual B4X code.




💡 How does it work?

Usage is very simple: just ask and GPT will deliver the full code.
Of course, it might make mistakes (that’s expected), but you can simply copy the log and feed it back in — it will revise and correct everything until the output is clean and working.

As we say where I come from: patience and collaboration are signs of strength.
And I want to lead the way — with you.




📝 Important Tip

After creating something, ask GPT – B4X BUILDER to generate a .md file summarizing any issues it encountered and how it resolved them.

Example prompt:
B4X:
What would you suggest updating in the B4X BUILDER prompt to correct all the errors you encountered?

📎 Attached is an example `.md` file created to help improve GPT accuracy and make B4X BUILDER even more reliable.




📤 Want to help?

If you get one of these `.md` logs from GPT — showing difficulties it faced — feel free to share it here as a file attachment.
I’ll review it and integrate it to make the assistant smarter, faster, and more B4X-focused.

Thanks to everyone who joins in 🙏
Ivano – MIASMART GPT Project


B4X:
' ============================================
' Module: CustomListViewCD (B4XMainPage compatibile)
' Created by: ALEX – MIASMART B4X BUILDER
' Technical support: MIASMART – B4X BUILDER v1
' Date: 2025-05-26
' Purpose: Custom ListView in B4XMainPage con immagine + testo + campo note
' ============================================

Sub Class_Globals
    Dim fx As JFX
    Private Root As B4XView
    Private xui As XUI
    Private sv As ScrollPane
    Private container As Pane
End Sub

Public Sub Initialize
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1

    sv.Initialize("sv")
    Root.AddView(sv, 0, 0, 600dip, 600dip)

    container.Initialize("")
    container.SetLayoutAnimated(0, 0, 0, 600dip, 95dip * 10 + 10dip)

    Dim jo As JavaObject = sv
    jo.RunMethod("setContent", Array(container))

    For i = 1 To 10
        AddCDRow("CD Titolo " & i, "Artista " & i, "io.png")
    Next
End Sub

Private Sub AddCDRow(titolo As String, sottotitolo As String, imgFile As String)
    Dim riga As Pane
    riga.Initialize("")
    riga.SetLayoutAnimated(0, 0, 0, 580dip, 90dip)
    Dim joRiga As JavaObject = riga
    joRiga.RunMethod("setStyle", Array("-fx-background-color: white;"))

    Dim img As ImageView
    img.Initialize("")
    Dim bmp As B4XBitmap = xui.LoadBitmap(File.DirAssets, imgFile)
    img.SetImage(bmp)
    riga.AddNode(img, 10dip, 15dip, 60dip, 60dip)

    Dim lblTitolo As Label
    lblTitolo.Initialize("")
    lblTitolo.Text = titolo
    lblTitolo.TextSize = 16
    riga.AddNode(lblTitolo, 80dip, 10dip, 300dip, 25dip)

    Dim lblSotto As Label
    lblSotto.Initialize("")
    lblSotto.Text = sottotitolo
    lblSotto.TextSize = 12
    lblSotto.TextColor = fx.Colors.Gray
    riga.AddNode(lblSotto, 80dip, 35dip, 300dip, 20dip)

    Dim txtNote As TextField
    txtNote.Initialize("")
    txtNote.PromptText = "Note..."
    riga.AddNode(txtNote, 80dip, 60dip, 300dip, 20dip)

    container.AddNode(riga, 10dip, container.NumberOfNodes * 95dip, 580dip, 90dip)
End Sub


1748332026603.png
 
Top