Android Question How to use JavaObject (or reflector) with ViewPropertyAnimator

moster67

Expert
Licensed User
Longtime User
Someone who can help to show me how to use ViewPropertyAnimator with JavaObject or Reflector (if it is possible).

Example in Java:

B4X:
private Button mButton;
mButton.animate().rotationBy(360.0f).setDuration(5000).start();

Thanks.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

moster67

Expert
Licensed User
Longtime User
Thank you Don but I was thinking of doing something as follows:

B4X:
Dim Obj1 As Reflector
Obj1.Target = myButton
Obj1.RunMethod("animate")
Obj1.RunMethod2("rotationBy",360.0f, "java.lang.float")
Obj1.RunMethod2("setDuration",5000, "java.lang.int")
Obj1.RunMethod("start")

but this will not work.

I can probably use inline-java or one of the plenty animations libraries available but I wanted to get it working either with Reflector or JavaObject (or a combination of both if necessary).
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
B4X:
Sub Rotate(view As View, Degree As Float, Duration As Int)
Dim jo As JavaObject = view
jo.RunMethodJO("animate", Null).RunMethodJO("rotationBy", Array(Degree)).RunMethodJO("setDuration", Array(Duration)).RunMethodJO("start", Null)
End Sub

I get this error:
java.lang.RuntimeException: Method: setDuration not matched.

B4X:
Sub Activity_Resume
    Rotate(pnlGreen, 30, 1000)
End Sub
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I know and tried but it does not work
I tried but very badly :D

First attempt was using a float, then I declared the argument as Float; same error.

Then I passed a Long, without change the "signature".


Sorry, thank you Erel.
 
Upvote 0
Top