Android Question problem with xCustomListView.AddTextItem

Discussion in 'Android Questions' started by Michael99k, Aug 30, 2018.

  1. Michael99k

    Michael99k Member Licensed User

    Hello,

    I´m new to B4A.
    I try to use xCustomListView and fail to add items.
    I want to use xCustomListView because of it´s customizability (e.g. possibility to set size of font/text,...)
    I´ve checked:
    1. The library is loaded (xCustomListView version 1.63)
    2. the view "clvList1" is drawn in the visual designer
    3. the member is created ("private clvList1 As CustomListView")
    When I try to add items with
    clvList1.AddTextItem("Hello")
    the compiler complains about missing params.
    That´s ok, because the context-sensitive help says: "AddTextItem (text as object, value as object) as object".
    But when I try to add items with
    clvList1.AddTextItem("Hello", "a")
    the compiler complains about to many params!

    I can replace the "a" with "", 1, a, or any other text, number or variable - the compiler still complains about to many params.
    The view itself works fine, if I leave it empty, but that makes no sense.

    What´s wrong and what do I have missed or misunterstood?
    What´s the sense of "value as object"? Is it like a .tag for each item which I can set to store information?
    How do I have to define the "value" before using it in .AddTextItem()?
    :(
     
  2. Michael99k

    Michael99k Member Licensed User

    The same error with the sample-project provided by Erel: look at attached screenshot!
     

    Attached Files:

  3. walterf25

    walterf25 Well-Known Member Licensed User

    It would really help to post your code so that it's easier for other members to help you.

    Walter
     
  4. Michael99k

    Michael99k Member Licensed User

    Thank you Walter, but there´s not much code yet:

    Code:
    Sub Globals   
        
    Private clvList1 As CustomListView
    End Sub

    Sub Activity_Create(FirstTime As Boolean)       
        
    Activity.LoadLayout("TeacherApp_Main")   
        clvList1.AddTextItem(
    "normal","")
        clvList1.AddTextItem(
    "super","")
    End Sub
    Before trying to use xCustomListView I used a normal listview. There it worked.
    But then I deleted the standard listview in the visual designer and replaced it, because there was no possibility to make the fontsize smaller. I added the xCustomListView as a customView, generated the member and tried to add an item...
     
  5. walterf25

    walterf25 Well-Known Member Licensed User

    If that's all you have as far as code, it should work, i don't see a reason why it shouldn't, you are passing the two parameters, so it should work.
    Can you upload your project, go to File then click Export As Zip, and upload your project so i can test here.

    Walter
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Moved to the questions forum.

    Please upload the project.
     
  7. Michael99k

    Michael99k Member Licensed User

    Hi,
    before uploading the project, I tried to create a new project - and it worked fine!
    I searched for the differences and found, that the module "CustomListView.bas" from the "xCustomListView.zip" is the problem in my project. When I remove the module then everything works fine. Problem solved, but many questions:

    Why don´t I need the module? What´s its purpose then?

    And still: What´s the sense of "value as object" in .AddTextItem?
    Is it like a .tag for each item which I can set to store information?

    Btw, CLV isn´t perfect for my purpose. Is there any other view in b4x like a classical windows dropdown-list (screenshot added)?
     

    Attached Files:

  8. Michael99k

    Michael99k Member Licensed User

    Found the B4XComboBox - I will look and see if it´s better for my project...

    But I still would like to understand and get answers to what I asked in my last post. I have to learn a lot...
    Thank you for your answers!!!
     
  9. DonManfred

    DonManfred Expert Licensed User

    It is the value you can give to be able to get it back in the Itemclick event

    Code:
    Sub clv_ItemClick (Index As Int, Value As Object)
        
    Activity.Title = Value
    End Sub
    You can use number, string for the Value. You also can use more complex values. Like a List or a Map. It´s up to you to use it or not (but can be of good help)...
     
    mangojack and Michael99k like this.
  10. Michael99k

    Michael99k Member Licensed User

    That seems useful DonManfred, Thank you!

    Do you or anybody know when it makes sense to integrate the module "CustomListView.bas" which Erel posted in his "xCustomListView.zip"? I mean, when methods like .AddTextItem work without this module (or only without)... ?
     
  11. DonManfred

    DonManfred Expert Licensed User

    Please start a new thread for any new question.
     
  12. 1lusca

    1lusca Member Licensed User

    Maybe you were using both clv code module and the clv library.
    I've had this same problem before, and this was the exact mistake.
     
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