Android Question Changing overscroll image of a listview

barx

Well-Known Member
Licensed User
Longtime User
It appears that the overscroll image of listviews can be changed using the 'setOverscrollHeader' and 'setOverscrollFooter' methods. Both supposedly expect a 'Drawable' as a parameter.

I have tried the following with reflector (very n00b on this subject ;)):

B4X:
    r.Target = lv 'a listview
   
    r.RunMethod2("setOverScrollMode", 0, "java.lang.int" )
    r.RunMethod2("setOverscrollHeader", res.GetAndroidDrawable("my_overscoll_glow"), "android.graphics.drawable.Drawable")

first off b4a give me a warning #7 - Pbject converted to string??

and I get an error on compile
java.lang.IllegalArgumentException: argument 1 should have type android.graphics.drawable.Drawable, got java.lang.String

I tried passing a drawable but b4a converts it to a string. Any tips on where I am going wrong.

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should use JavaObject, it is usually simpler:
B4X:
Dim jlv As JavaObject = lv
jlv.RunMethod("setOverScrollMode", Array As Object(0))
jlv.RunMethod("setOverscrollHeader", Array As Object(res.GetAndroidDrawable("my_overscoll_glow")))

The problem in your code is that Reflector.RunMethod2 expects a string. You can use Reflector.RunMethod4.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Thanks for the help Erel,

Forgot about JavaObject, it does indeed seem simpler and no error. It doesn't make any difference to the listview, but that is just android. So, for anybody reading this in the future, the above doesn't seem to work, sorry getting your hopes up.

I guess the thread can be deleted now. Cheers
 
Upvote 0
Top