moster67 Expert Licensed User Longtime User Aug 8, 2016 #1 Someone who can help to show me how to use ViewPropertyAnimator with JavaObject or Reflector (if it is possible). Example in Java: Code: private Button mButton; mButton.animate().rotationBy(360.0f).setDuration(5000).start(); Thanks. Last edited: Aug 8, 2016
Someone who can help to show me how to use ViewPropertyAnimator with JavaObject or Reflector (if it is possible). Example in Java: Code: private Button mButton; mButton.animate().rotationBy(360.0f).setDuration(5000).start(); Thanks.
DonManfred Expert Licensed User Longtime User Aug 8, 2016 #2 i guess you need to get a ref to https://developer.android.com/reference/android/view/ViewPropertyAnimator.html and then work with it´s methods... Upvote 0
i guess you need to get a ref to https://developer.android.com/reference/android/view/ViewPropertyAnimator.html and then work with it´s methods...
moster67 Expert Licensed User Longtime User Aug 8, 2016 #3 Thank you Don but I was thinking of doing something as follows: Code: 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
Thank you Don but I was thinking of doing something as follows: Code: 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).
DonManfred Expert Licensed User Longtime User Aug 8, 2016 #4 I guess you need to get an reference to the animator. initializestatic or so? with the animator then you can use the methods you posted in post#1 i guess. Sorry, i´m not really familar with JO Upvote 0
I guess you need to get an reference to the animator. initializestatic or so? with the animator then you can use the methods you posted in post#1 i guess. Sorry, i´m not really familar with JO
moster67 Expert Licensed User Longtime User Aug 8, 2016 #5 DonManfred said: Sorry, i´m not really familar with JO Click to expand... Neither am I Thanks anyway! Upvote 0
DonManfred said: Sorry, i´m not really familar with JO Click to expand... Neither am I Thanks anyway!
Erel B4X founder Staff member Licensed User Longtime User Aug 8, 2016 #6 Code: Sub Rotate(view As View, Degree As Float, Duration As Long) Dim jo As JavaObject = view jo.RunMethodJO("animate", Null).RunMethodJO("rotationBy", Array(Degree)).RunMethodJO("setDuration", Array(Duration)).RunMethodJO("start", Null) End Sub Last edited: Feb 13, 2017 Upvote 0
Code: Sub Rotate(view As View, Degree As Float, Duration As Long) Dim jo As JavaObject = view jo.RunMethodJO("animate", Null).RunMethodJO("rotationBy", Array(Degree)).RunMethodJO("setDuration", Array(Duration)).RunMethodJO("start", Null) End Sub
moster67 Expert Licensed User Longtime User Aug 8, 2016 #7 Seeing the code required, it was much simpler than I thought Thank you Erel. Upvote 0
LucaMs Expert Licensed User Longtime User Feb 13, 2017 #8 Erel said: Code: 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 Click to expand... I get this error: java.lang.RuntimeException: Method: setDuration not matched. Code: Sub Activity_Resume Rotate(pnlGreen, 30, 1000) End Sub Upvote 0
Erel said: Code: 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 Click to expand... I get this error: java.lang.RuntimeException: Method: setDuration not matched. Code: Sub Activity_Resume Rotate(pnlGreen, 30, 1000) End Sub
Erel B4X founder Staff member Licensed User Longtime User Feb 13, 2017 #9 The code was wrong. Duration type should be Long. Upvote 0
LucaMs Expert Licensed User Longtime User Feb 13, 2017 #10 Erel said: The code was wrong. Duration type should be Long. Click to expand... I know and tried but it does not work Upvote 0
Erel said: The code was wrong. Duration type should be Long. Click to expand... I know and tried but it does not work
LucaMs Expert Licensed User Longtime User Feb 13, 2017 #11 LucaMs said: I know and tried but it does not work Click to expand... I tried but very badly 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
LucaMs said: I know and tried but it does not work Click to expand... I tried but very badly 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.
Erel B4X founder Staff member Licensed User Longtime User Feb 13, 2017 #12 Works fine here. Are you testing it on Android 4+ device? Upvote 0