Android Tutorial Listview Divider Line Color

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can do it with the Reflection library:
B4X:
SetDivider(ListView1, Colors.Blue, 1dip)

Sub SetDivider(lv As ListView, Color As Int, Height As Int)
   Dim r As Reflector
   r.Target = lv
   Dim CD As ColorDrawable
   CD.Initialize(Color, 0)
   r.RunMethod4("setDivider", Array As Object(CD), Array As String("android.graphics.drawable.Drawable"))
   r.RunMethod2("setDividerHeight", Height, "java.lang.int")
End Sub
 

alfcen

Well-Known Member
Licensed User
Longtime User
Bravo!

In analogy to "setDivider" is there something like "setBackgroundColorOnSelect"?
It is persistantly cyan on my phone.
 

vasper

Member
Licensed User
Longtime User
can a method like that be used to change the typeface on a listview? also I cannot change color?
 

alfcen

Well-Known Member
Licensed User
Longtime User
There is a much simpler means:

B4X:
Dim MyFont As Typeface
MyFont = Typeface.LoadFromAssets("dummy.ttf")
ListView1.TwoLinesAndBitmap.Label.Typeface = MyFont
ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Red
 
Top