stevel05 Expert Licensed User Longtime User Jun 25, 2012 #1 I'm probably trying to do something that is not supposed to work, but I have passed the activity to a class and then loaded a layout within the class. The layout is displayed and in the example attached, the DrawBtn_Click method fires as expected, but the EditText1_EnterPressed fails with the error Object should first be initialized. If I initialize the views within the class, the DrawBtn_Click still fires, but the EditText_EnterPressed does not return the text, presumably a new EditText is created with the initialization. It would be useful if this would work, but I imagine that it is down to differences in the complexity of the wrappers of each view. Attachments test.zip test.zip 7.2 KB · Views: 402 Last edited: Jun 25, 2012
I'm probably trying to do something that is not supposed to work, but I have passed the activity to a class and then loaded a layout within the class. The layout is displayed and in the example attached, the DrawBtn_Click method fires as expected, but the EditText1_EnterPressed fails with the error Object should first be initialized. If I initialize the views within the class, the DrawBtn_Click still fires, but the EditText_EnterPressed does not return the text, presumably a new EditText is created with the initialization. It would be useful if this would work, but I imagine that it is down to differences in the complexity of the wrappers of each view.
stevel05 Expert Licensed User Longtime User Oct 26, 2012 #21 Wow, I think that may open a can of worms. You can iterate over the views and get the information, but I think you would have to rebuild the layout in code, effectively duplicating the layout as you would have to dim and initialize the variables somewhere. Sounds like you are trying to write a generic handler. Maybe someone has an idea how it might work. Sent from my HTC Sensation XE with Beats Audio Z715e using Tapatalk 2 Upvote 0
Wow, I think that may open a can of worms. You can iterate over the views and get the information, but I think you would have to rebuild the layout in code, effectively duplicating the layout as you would have to dim and initialize the variables somewhere. Sounds like you are trying to write a generic handler. Maybe someone has an idea how it might work. Sent from my HTC Sensation XE with Beats Audio Z715e using Tapatalk 2
Informatix Expert Licensed User Longtime User Oct 26, 2012 #22 eelias said: Sadly DoEvents is doing nothing, the CallSub3 is not ever getting there (I place a breakpoint and it never happens) If SubExists(Module, "OnLoadLayout") Then CallSub3(Module, "OnLoadLayout", LayOut, Pan) End If Click to expand... I tried it and that works fine. Here's the proof. Attachments Yes_it_works.zip Yes_it_works.zip 13.1 KB · Views: 485 Upvote 0
eelias said: Sadly DoEvents is doing nothing, the CallSub3 is not ever getting there (I place a breakpoint and it never happens) If SubExists(Module, "OnLoadLayout") Then CallSub3(Module, "OnLoadLayout", LayOut, Pan) End If Click to expand... I tried it and that works fine. Here's the proof.
Informatix Expert Licensed User Longtime User Oct 26, 2012 #23 margret said: I am trying to find a way to trigger an event in the class with no dimmed views from the Layout, either in the class or in the Activity. Click to expand... Here's a solution with no Dim. The event is received by the class, but handled by the activity module. Attachments Yes_it_works2.zip Yes_it_works2.zip 339.4 KB · Views: 541 Upvote 0
margret said: I am trying to find a way to trigger an event in the class with no dimmed views from the Layout, either in the class or in the Activity. Click to expand... Here's a solution with no Dim. The event is received by the class, but handled by the activity module.
margret Well-Known Member Licensed User Longtime User Oct 26, 2012 #24 I am going to download and check this now!! I'll report back and WOW! Upvote 0
margret Well-Known Member Licensed User Longtime User Oct 26, 2012 #25 I changed layout1.bal to one of mine, it does not fire the click event in the Class or the Activity. What did I miss? Last edited: Oct 26, 2012 Upvote 0
I changed layout1.bal to one of mine, it does not fire the click event in the Class or the Activity. What did I miss?
Informatix Expert Licensed User Longtime User Oct 26, 2012 #26 margret said: I changed layout1.bal to one of mine, it does not fire the click event in the Class or the Activity. What did I miss? Click to expand... Because of the panels. My loop, in the example, doesn't explore the panels to assign the click listeners. You should do a recursive function. Upvote 0
margret said: I changed layout1.bal to one of mine, it does not fire the click event in the Class or the Activity. What did I miss? Click to expand... Because of the panels. My loop, in the example, doesn't explore the panels to assign the click listeners. You should do a recursive function.
margret Well-Known Member Licensed User Longtime User Oct 26, 2012 #27 Got It! I now have it looking in the Panel. Now I will see if I can get all the other stuff doing what I need. This is AWESOME! THANK YOU:sign0188: Upvote 0
Got It! I now have it looking in the Panel. Now I will see if I can get all the other stuff doing what I need. This is AWESOME! THANK YOU:sign0188:
Uitenhage Member Licensed User Longtime User Feb 1, 2014 #28 Informatix (or Agraham?), I used your "Yes_it_works2" example from this thread and it worked exactly as expected. I tried to extend it to include LongClicks and got unexpected results . I cloned the SetOnClickListener line in the class Initialize Sub and changed it to SetOnLongClickListener. I cloned the Click subs in the class and in Main and changed all the Click references in the clones to LongClick. Now I expected the same behavior on a long click as a click. Click works as previously but long click produces a messagebox "Unfortunately, Layout change example has stopped". Under Debug (legacy) this appears in the log: Installing file. PackageAdded: package:b4a.example ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** java.lang.NullPointerException at android.view.View.showContextMenu(View.java:4545) at android.view.View.performLongClick(View.java:4514) at android.widget.TextView.performLongClick(TextView.java:9575) at android.view.View$CheckForLongPress.run(View.java:18768) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5455) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) at dalvik.system.NativeStart.main(Native Method) What have I missed? Compiled both in Release and Debug (legacy) using B4A v3.20 and Reflection 2.40 on a Galaxy S3. Thanks, Jim Upvote 0
Informatix (or Agraham?), I used your "Yes_it_works2" example from this thread and it worked exactly as expected. I tried to extend it to include LongClicks and got unexpected results . I cloned the SetOnClickListener line in the class Initialize Sub and changed it to SetOnLongClickListener. I cloned the Click subs in the class and in Main and changed all the Click references in the clones to LongClick. Now I expected the same behavior on a long click as a click. Click works as previously but long click produces a messagebox "Unfortunately, Layout change example has stopped". Under Debug (legacy) this appears in the log: Installing file. PackageAdded: package:b4a.example ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** java.lang.NullPointerException at android.view.View.showContextMenu(View.java:4545) at android.view.View.performLongClick(View.java:4514) at android.widget.TextView.performLongClick(TextView.java:9575) at android.view.View$CheckForLongPress.run(View.java:18768) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5455) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) at dalvik.system.NativeStart.main(Native Method) What have I missed? Compiled both in Release and Debug (legacy) using B4A v3.20 and Reflection 2.40 on a Galaxy S3. Thanks, Jim
Erel B4X founder Staff member Licensed User Longtime User Feb 2, 2014 #29 This is an old thread. Please start a new thread. The issue discussed in this thread was already fixed. Upvote 0
This is an old thread. Please start a new thread. The issue discussed in this thread was already fixed.