Android Question Ask Initialize customview inserted with designer

makis_best

Active Member
Licensed User
Hello

I insert into a Layout with the help of the designer one B4XTable custom view.
When I run the application I get one error saying that I need to initialize the view.

Why?

java.lang.RuntimeException: Class instance was not initialized (b4xtable)
 
Last edited:

walterf25

Expert
Licensed User
Hello

I insert into a Layout with the held of the designer one B4XTable custom view.
When I run the application I get one error saying that I need to initialize the view.

Why?
In this cases, it is better to show the relevant parts of your code or upload the project so we can help you out.

From the File Menu -> Export As Zip

Walter
 

klaus

Expert
Licensed User
You need to give more information.
The best way to help you would be to post a test project showing the problem.
That way we could see what exactly you have done and a give you a concrete advice.
 

DonManfred

Expert
Licensed User
1. This code will not do anything useful
B4X:
    '=======================================================
    'B4XTable1.Initialize(Activity, "B4XTable1")
'    editCol = B4XTable1.AddColumn("Επεξεργασία", B4XTable1.COLUMN_TYPE_TEXT)
'    editCol.Sortable = False
'    editCol.Width = 127dip
'    B4XTable1.RowHeight = 50dip
'    B4XTable1.NumberOfFrozenColumns = 1
'    B4XTable1.AddColumn("Κωδικός", B4XTable1.COLUMN_TYPE_TEXT)
'    B4XTable1.AddColumn("Περιγραφή", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Μ.Μ.", B4XTable1.COLUMN_TYPE_TEXT)
'    B4XTable1.AddColumn("Τιμή", B4XTable1.COLUMN_TYPE_NUMBERS)
'    B4XTable1.AddColumn("1η Εκπτ.", B4XTable1.COLUMN_TYPE_NUMBERS)
'    B4XTable1.AddColumn("2η Εκπτ.", B4XTable1.COLUMN_TYPE_NUMBERS)
'    B4XTable1.AddColumn("Ποσότητα", B4XTable1.COLUMN_TYPE_NUMBERS)
'    B4XTable1.AddColumn("Σύνολο", B4XTable1.COLUMN_TYPE_NUMBERS)
'    B4XTable1.AddColumn("% Φ.Π.Α.", B4XTable1.COLUMN_TYPE_NUMBERS)
'    B4XTable1.AddColumn("Φ.Π.Α.", B4XTable1.COLUMN_TYPE_NUMBERS)
'    B4XTable1.AddColumn("Σχόλιο", B4XTable1.COLUMN_TYPE_TEXT)
'    PrefDialog.Initialize(Activity, "Επεξεγασία είδους", 300dip, 300dip)
'    PrefDialog.AddNumberItem("PPrice", "Τιμή")
'    PrefDialog.AddOptionsItem("QQuant123", "Ποσότητα123", Array(1.23, 1.45, 1.68))
'    PrefDialog.AddNumberItem("QQuant", "Ποσότητα")
'    PrefDialog.AddTextItem("CComment", "Σχόλιο")
'    PrefDialog.SearchTemplate.MaxNumberOfItemsToShow = 300
'    B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
    'Sleep(0)
    'B4XTable1.SearchField.mBase.Visible=False
'    For i = 1 To editCol.CellsLayouts.Size - 1
'        Dim p As B4XView = editCol.CellsLayouts.Get(i)
'        p.AddView(CreateButton("btnEdit", Chr(0xF044)), 2dip, 5dip, 40dip, 40dip)
'        p.AddView(CreateButton("btnDelete", Chr(0xF00D)), 44dip, 5dip, 40dip, 40dip)
'        'p.AddView(EdTb.CreateButton("btnDuplicate",Chr(0xF0C5)), 85dip, 5dip, 40dip, 40dip)
'    Next
    'B4XTable1.SetData(Data)
    '=======================================================
2. Why you are not using layouts?
3. You question is about customlistview but the error is pointing to B4XTABLE. AND you are NOT USING this layout (if there is one with a customlistview or a b4xtable)
 
Last edited:

makis_best

Active Member
Licensed User
Sorry.... Probably my fault.....
I erase many things from the test to make it simple and I didn't realize that I erase and the layout.
I load Layout in the activity.load I just erase it by mistake.
 

klaus

Expert
Licensed User
In the ESFIItems module you load two layouts:
ESFIItems and left, none of these layouts contains a B4XTable CustomView.
So, again, in which layout have you defined the B4XTable CustomView?
You have commented the loading of Layout1, but the Laout1 file doesn't exist in your project!?
Have you tested the project in post #4 before you posted it?
 

makis_best

Active Member
Licensed User
I test it And the Layout you asking for is
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Data.Initialize
    AFMEditText.Initialize("AFMEditText")
    Ime1.Initialize("Ime1")
    Drawer.Initialize(Me, "Drawer", Activity, 250dip)
    Drawer.CenterPanel.LoadLayout("Document_EIDH")
 

klaus

Expert
Licensed User
Sorry, it seems that we are not speaking of the same program!
The code of the program in post #4 is this:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Data.Initialize
    AFMEditText.Initialize("AFMEditText")
    Ime1.Initialize("Ime1")
    Drawer.Initialize(Me, "Drawer", Activity, 250dip)
    Drawer.CenterPanel.LoadLayout("ESFIItems")
So how do you expect us to help you when you provide wrong information.
Now you changed the layout, do you still get the error?
 
Top