Android Question Change Scrollbar Color of listview

Salar82

Member
Hi All
I want to change scrollbar color of listview; not customlistview.
how can I do it like this:

SS-2018-02-21_08.22.41.png


doas it possible?
 

Salar82

Member
now I use xcustomlistview; I tried to use this Sub:
B4X:
Sub SetScrollbarColor(sv As ScrollView, clr As Int)
   Dim r As Reflector
   r.Target = sv
   r.Target = r.GetField("mScrollCache")
   r.Target = r.GetField("scrollBar")
   Dim cd As ColorDrawable
   cd.Initialize(clr, 5dip)
   r.RunMethod4("setVerticalThumbDrawable", Array(cd), Array As String("android.graphics.drawable.Drawable"))
End Sub

https://www.b4x.com/android/forum/threads/scrollbar-color.89818/


but I get the following error on line 5 ( r.Target = r.GetField("scrollBar") :

B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
    at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:205)
    at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod4(Reflection.java:857)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at com.oilcontrol.ash.addcar.afterFirstLayout(addcar.java:104)
    at com.oilcontrol.ash.addcar.access$000(addcar.java:17)
    at com.oilcontrol.ash.addcar$WaitForLayout.run(addcar.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6198)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)

I use this code:
B4X:
SetScrollbarColor(xcustomlistview.AsView , Colors.Red)
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see:

 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see:
 
Upvote 0
Top