Android Question Ask Initialize customview inserted with designer

Discussion in 'Android Questions' started by makis_best, Apr 23, 2019.

  1. makis_best

    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?

     
    Last edited: Apr 23, 2019
  2. walterf25

    walterf25 Well-Known Member Licensed User

    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
     
  3. klaus

    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.
     
    walterf25 likes this.
  4. makis_best

    makis_best Active Member Licensed User

    Here it is a test file Check ESFIitems.bas
     

    Attached Files:

  5. DonManfred

    DonManfred Expert Licensed User

    1. This code will not do anything useful
    Code:
    '=======================================================
        '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: Apr 23, 2019
  6. klaus

    klaus Expert Licensed User

    I don't see where you add the B4XTable in a Layout !?
     
  7. makis_best

    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.
     
  8. klaus

    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?
     
  9. makis_best

    makis_best Active Member Licensed User

    I test it And the Layout you asking for is
    Code:
    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"Activity250dip)
        Drawer.CenterPanel.LoadLayout(
    "Document_EIDH")
     
  10. klaus

    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:
    Code:
    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"Activity250dip)
        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?
     
  11. DonManfred

    DonManfred Expert Licensed User

    In addition to Klaus answer:
    If you still encounter an Error. WHICH ONE? Where is the new projectupload?

    Hard to help you with the Infos you are providing.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice