Android Question problem with xCustomListView.AddTextItem

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()?
:(
 

Michael99k

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

Attachments

  • 2018-08-31 00_08_24-xCustomListView - B4A.png
    2018-08-31 00_08_24-xCustomListView - B4A.png
    84 KB · Views: 284
Upvote 0

walterf25

Expert
Licensed User
Longtime User
The same error with the sample-project provided by Erel: look at attached screenshot!
It would really help to post your code so that it's easier for other members to help you.

Walter
 
Upvote 0

Michael99k

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

B4X:
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...
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Thank you Walter, but there´s not much code yet:

B4X:
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...
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
 
Upvote 0

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)?
 

Attachments

  • 2018-08-31 07_40_54-dropdown liste - Google-Suche – Opera.png
    2018-08-31 07_40_54-dropdown liste - Google-Suche – Opera.png
    225.2 KB · Views: 262
Upvote 0

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!!!
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
And still: What´s the sense of "value as object" in .AddTextItem?
It is the value you can give to be able to get it back in the Itemclick event

B4X:
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)...
 
Upvote 0

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)... ?
 
Upvote 0

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.
 
Upvote 0
Top