Hi all,
as for thread title, can setLayoutAnimated be called inside a Class ?
I use this code:
The TextConsole and TextLabel controls are added by code in the Class Initialize method this way:
When I compile this is the error message.
Many thanks
as for thread title, can setLayoutAnimated be called inside a Class ?
I use this code:
B4X:
'Show a console with layout animation.
'Duration: The animation duration in milliseconds. Pass 0 for no animation.
Sub ShowConsole (Duration As Int)
mDuration = Duration ' Store for future uses
mTextConsole.SetLayoutAnimated(mDuration, 0, 100%y-mHeight, 100%x, mHeight)
mLabelConsole.SetLayoutAnimated(mDuration, 0, 64%y, 100%x, 20dip)
mLogActive = True
End Sub
'Hide a console with layout animation.
'Duration: The animation duration in milliseconds. Pass 0 for no animation.
Sub HideConsole(Duration As Int)
mDuration = Duration ' Store for future uses
mTextConsole.SetLayoutAnimated(mDuration, 0, 100%y, 100%x, mHeight)
mLabelConsole.SetLayoutAnimated(mDuration, 0, 100%y, 100%x, 20dip)
mLogActive = False
End Sub
B4X:
'Inizialize the JSConsole object.
Public Sub Initialize(Parent As Panel, Module As Object, EventName As String, WebView As WebView, Height As Float)
mParent = Parent
mModule = Module
mEventName = EventName.ToLowerCase
mHeight = Height
mWebView1 = WebView
mWebView1.Initialize("mWV1")
mTextConsole.Initialize("TextConsole")
mTextConsole.TextSize = 10
mTextConsole.Typeface = Typeface.SANS_SERIF
mTextConsole.Color = Colors.DarkGray
mTextConsole.TextColor = Colors.Green
mTextConsole.Gravity = Gravity.LEFT + Gravity.TOP
mTextConsole.Padding = Array As Int (3dip, 23dip, 3dip, 3dip)
mTextConsole.Text = "Ready" & CRLF & CRLF
mParent.AddView(mTextConsole, 0, 100%y-Height, 100%x, Height)
mLabelConsole.Initialize("LabelConsole")
mLabelConsole.TextSize = 12
mLabelConsole.Typeface = Typeface.DEFAULT_BOLD
mLabelConsole.Color = Colors.Blue
mLabelConsole.TextColor = Colors.LightGray
mLabelConsole.Gravity = Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL
mLabelConsole.Padding = Array As Int (1dip, 1dip, 1dip, 1dip)
mLabelConsole.Text = "JS CONSOLE"
mParent.AddView(mLabelConsole, 0, 100%y-Height, 100%x, 20dip)
When I compile this is the error message.
Many thanks
** Activity (main) Resume **
jsconsole_hideconsole (java line: 98)
java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to anywheresoftware.b4a.BALayout$LayoutParams
at anywheresoftware.b4a.objects.ViewWrapper.SetLayoutAnimated(ViewWrapper.java:337)
at b4a.console.jsconsole._hideconsole(jsconsole.java:98)
at b4a.console.jsconsole._labelconsole_click(jsconsole.java:183)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5225)
at android.view.View$PerformClick.run(View.java:21195)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Last edited: