B4J Question Cards list with CustomListView for B4J

floatingpoint

Member
Licensed User
Longtime User
Just getting into the B4J environment and am looking to start with the B4A example here:
https://www.b4x.com/android/forum/threads/cards-list-with-customlistview.87720/#content

However I'm stuck on the javafx equivalent of the
(run time error - java.lang.ClassNotFoundException: android$content$res$ColorStateList)
B4X:
Sub SetColorStateList(Btn As Label,Pressed As Int,Enabled As Int)
   Dim States(2,1) As Int
   States(0,0) = 16842919    'Pressed
   States(1,0) = 16842910    'Enabled
   Dim CSL As JavaObject
   CSL.InitializeNewInstance("android.content.res.ColorStateList",Array(States,Array As Int(Pressed, Enabled)))
   Dim B1 As JavaObject = Btn
   B1.RunMethod("setTextColor",Array As Object(CSL))
End Sub

Suggestions greatly appreciated.
FP
 
Last edited:

floatingpoint

Member
Licensed User
Longtime User
This is an Android specific API. It will not work in B4J.

Start without it. Just set the label's color in the designer.
Note that the click event signature is:
B4X:
Sub lblAction1_MouseClicked (EventData As MouseEvent)

Great, thank you Erel.

My next task is to display multiple cards per scroll position to make efficient use of screen space.
My plan is to use a singe holding panel per scroll onto which multiple panels/ cards will be placed.
Is this the best approach?

FP
 
Upvote 0

floatingpoint

Member
Licensed User
Longtime User
Yes. You can make a layout file with a panel that holds two panels and then load the cards layout to each of these panels.
Thank you,

I started down this path but ran into some 'index out of range' and 'no click event' run time issues.
To keep things simple and not alter Custom List View class which will be reused for other pages, for the time being I have decided to stay at one card per scroll position.
I may revisit this later in the project when I am more familiar with the code. :)
 
Upvote 0
Top