Hi all, I'm trying to localize my app using AndroidResources library.
What I want is to update all views with .text properties using relative .tag property.
I save(manually) the key of xml resource file in the tag property and then I use it for updating the object's strings.
I've prepared a test app with a button, a label and an editext, this is the code:
Someone knows why I get this error?
P.S. however the value of label, button and edittext are updated fine...
What I want is to update all views with .text properties using relative .tag property.
I save(manually) the key of xml resource file in the tag property and then I use it for updating the object's strings.
I've prepared a test app with a button, a label and an editext, this is the code:
B4X:
Sub Globals
Dim AR As AndroidResources
Dim key As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
SetLang
End Sub
Sub SetLang
For Each lbl As Label In Activity
key=lbl.Tag
lbl.Text=AR.GetApplicationString(key)
Next
For Each etxt As EditText In Activity
key=etxt.Tag
etxt.Text=AR.GetApplicationString(key)
Next
For Each btn As Button In Activity
key=btn.Tag
btn.Text=AR.GetApplicationString(key)
Next
End Sub
Someone knows why I get this error?
B4X:
** Activity (main) Create, isFirst = false**
main_setlang (java line: 303)
java.lang.ClassCastException: android.widget.Button
at test.multilang.main._setlang(main.java:303)
at test.multilang.main._activity_create(main.java:237)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at test.multilang.main.afterFirstLayout(main.java:89)
at test.multilang.main.access$100(main.java:16)
at test.multilang.main$WaitForLayout.run(main.java:74)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: android.widget.Button
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
P.S. however the value of label, button and edittext are updated fine...
Last edited: