Hi All, today's dumb question.
I am seeking to find the elevation of buttons, I have searched but can't find anything to get elevation but SetElevation gives a bit of a clue.
Below are a couple of attempts using javaobject and reflection libraries without success.
Question 1. Is this possible in B4A? Java has a GetElevation but I might be looking at a dead end in B4A.
Question 2. If it is possible, can someone please point at what I have done wrong.
Regards Roger
With Reflection library.
Crashes on "Launch", seems to say there is no such thing as getElevation.
With JavaObject library
Crashes on "Launch" like reflection library.
I am seeking to find the elevation of buttons, I have searched but can't find anything to get elevation but SetElevation gives a bit of a clue.
Below are a couple of attempts using javaobject and reflection libraries without success.
Question 1. Is this possible in B4A? Java has a GetElevation but I might be looking at a dead end in B4A.
Question 2. If it is possible, can someone please point at what I have done wrong.
Regards Roger
With Reflection library.
Crashes on "Launch", seems to say there is no such thing as getElevation.
Error occurred on line: 56 (Main)
java.lang.NoSuchMethodException: java.lang.Object.getElevation []
at java.lang.Class.getMethod(Class.java:2072)
at java.lang.Class.getDeclaredMethod(Class.java:2050)
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod(Reflection.java:802)
B4X:
Sub GetElevation
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Private r As Reflector
Private F1 As Float
r.Target = r.GetActivity
F1 = r.RunMethod("getElevation")
Log(F1)
End If
Next
End Sub
With JavaObject library
Crashes on "Launch" like reflection library.
Error occurred on line: 54 (Main)
java.lang.RuntimeException: Method: getelevation not found in: android.widget.Button
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:366)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
B4X:
Sub GetElevation
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Private jo As JavaObject = v
Private F1 As Float
Private F1 As Float = jo.RunMethod("getelevation", Null)
Log(F1)
End If
Next
End Sub