I'm having problem with class "within" a class.
1) Main initialize class "firstclass", passing callbackmodule ("main") and event ("from1st")
2) Main has a sub from1st
3) class "firstclass" initialize another class ("secondcalss"), passing callbackmodule("firstclass") and event ("from2nd")
4) firstclass has sub from2nd, it does something and then calls its own callback/event (main/from1st)
5) class "secondclass" defines a button witch a click event
6) the click event does something and then calls its own callback/event (firstclass/from2nd)
The click event cause an error.
A) when class inits are called with Me the error is:
java.lang.ClassNotFoundException: boten.cls1.[event=from1st, main=null, parent=class boten.cls1.main[/b]
B) when class inits are called with explicit names ("Main" & "firstclass") the error is:
java.lang.NoSuchFieldException: processBA
How can I do this. Attached is an sample project.
logs are here:
log for case A
log for case B
1) Main initialize class "firstclass", passing callbackmodule ("main") and event ("from1st")
2) Main has a sub from1st
3) class "firstclass" initialize another class ("secondcalss"), passing callbackmodule("firstclass") and event ("from2nd")
4) firstclass has sub from2nd, it does something and then calls its own callback/event (main/from1st)
5) class "secondclass" defines a button witch a click event
6) the click event does something and then calls its own callback/event (firstclass/from2nd)
The click event cause an error.
A) when class inits are called with Me the error is:
java.lang.ClassNotFoundException: boten.cls1.[event=from1st, main=null, parent=class boten.cls1.main[/b]
B) when class inits are called with explicit names ("Main" & "firstclass") the error is:
java.lang.NoSuchFieldException: processBA
How can I do this. Attached is an sample project.
logs are here:
log for case A
B4X:
** Activity (main) Create, isFirst = true **
1st class init: Parent=class boten.cls1.main Event=from1st
2nd class init: Parent=[event=from1st, main=null, parent=class boten.cls1.main
, pnl=(BALayout): Left=0, Top=0, Width=480, Height=724, second=[btn=(Button) Not initialized, event=, main=null
, parent=, pnl=(Panel) Not initialized]] Event=from2nd
** Activity (main) Resume **
2nd class: 0
secondclass_btn_click (java line: 33)
java.lang.ClassNotFoundException: boten.cls1.[event=from1st, main=null, parent=class boten.cls1.main
, pnl=(balayout): left=0, top=0, width=480, height=724, second=[btn=(button) not initialized, event=, main=null
, parent=, pnl=(panel) not initialized]]
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:235)
at java.lang.Class.forName(Class.java:182)
at anywheresoftware.b4a.keywords.Common.getComponentBA(Common.java:912)
at anywheresoftware.b4a.keywords.Common.SubExists(Common.java:758)
at boten.cls1.secondclass._btn_click(secondclass.java:33)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:149)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:55)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8816)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: boten.cls1.[event=from1st, main=null, parent=class boten.cls1.main
, pnl=(balayout): left=0, top=0, width=480, height=724, second=[btn=(button) not initialized, event=, main=null
, parent=, pnl=(panel) not initialized]]
... 22 more
Caused by: java.lang.ClassNotFoundException: boten.cls1.[event=from1st, main=null, parent=class boten.cls1.main
, pnl=(balayout): left=0, top=0, width=480, height=724, second=[btn=(button) not initialized, event=, main=null
, parent=, pnl=(panel) not initialized]] in loader dalvik.system.PathClassLoader[/data/app/boten.cls1-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
... 22 more
log for case B
B4X:
** Activity (main) Create, isFirst = true **
1st class init: Parent=Main Event=from1st
2nd class init: Parent=firstclass Event=from2nd
** Activity (main) Resume **
2nd class: 0
secondclass_btn_click (java line: 33)
java.lang.NoSuchFieldException: processBA
at java.lang.ClassCache.findFieldByName(ClassCache.java:510)
at java.lang.Class.getField(Class.java:881)
at anywheresoftware.b4a.keywords.Common.getComponentBA(Common.java:913)
at anywheresoftware.b4a.keywords.Common.SubExists(Common.java:758)
at boten.cls1.secondclass._btn_click(secondclass.java:33)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:149)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:55)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8816)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NoSuchFieldException: processBA