Android Question [solved] IME - Error ?

D

Deleted member 103

Guest
Hi,

I do not understand this error message. Which parent is all about?
The library IME has no parent, right?

I know that if the activity is FullScreen, the library will not work.
In my case, however, the activity has this property:

B4X:
#Region  Activity Attributes
    #FullScreen: false
    #IncludeTitle: true
#End Region
Error occurred on line: 242 (Main)
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:4466)
at android.view.ViewGroup.addView(ViewGroup.java:4307)
at android.view.ViewGroup.addView(ViewGroup.java:4247)
at android.view.ViewGroup.addView(ViewGroup.java:4220)
at anywheresoftware.b4a.objects.IME.AddHeightChangedEvent(IME.java:119)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at fg.Crono4Timekeeper.pro.main.afterFirstLayout(main.java:104)
at fg.Crono4Timekeeper.pro.main.access$000(main.java:17)
at fg.Crono4Timekeeper.pro.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:6459)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:938)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)

Everything worked fine in my previous app version. With this new app version I'm using "Appcompat" and "SlidingMenu" and now it does not work anymore.
IME-Error.JPG
 
D

Deleted member 103

Guest
Have you declared ime1 as Public in the Process_Globals?

It seems to me that it is initialized twice.
An activity can not be defined in Process_Globals, it can only be defined in Sub Globals.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Sometimes it happened to me that the error line number was not the right one.
This could be the case or the initialization occurs twice (I do not know how, since the log is: "Activity_Create, isFirst = True").

You could solve this by inserting a Try block (but this is not the best solution).
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
B4X:
IMeI.Initialize("IMeI")
IMeI.AddHandleActionEvent(View) ' Missing
IMeI.AddHeightChangedEvent

To handle the event you must also associate it with a view, such as an editText. What's missing in your code.

The generation of the error makes me believe that it is trying to handle the keyboard event by trying to associate it with some view we do not know
 
Upvote 0
D

Deleted member 103

Guest
B4X:
IMeI.Initialize("IMeI")
IMeI.AddHandleActionEvent(View) ' Missing
IMeI.AddHeightChangedEvent

To handle the event you must also associate it with a view, such as an editText. What's missing in your code.

The generation of the error makes me believe that it is trying to handle the keyboard event by trying to associate it with some view we do not know
I think the bug has something to do with the library appcompat and SlidingMenu, because without this 2 library works properly.
 
Upvote 0
D

Deleted member 103

Guest
Problem solved!

If I initialize the library IME after initializing SlidingMenu, then the app crashes.
But if I initialize the library IME before initializing SlidingMenu, then everything is working properly.

This is how the app crashes:
B4X:
    sm.Initialize("sm")
    Dim offset As Int = 30%x
    sm.BehindOffset = offset
    sm.Mode = sm.LEFT
    Dim lftMenu As Panel
    lftMenu.Initialize("")
    sm.Menu.AddView(lftMenu, 0, 0, 100%x - offset, 100%y)
    lftMenu.LoadLayout("frmMenu")

    'Library zum Einblenden/Ausblenden der Tastatur.
    ime1.Initialize("ime1")
    ime1.AddHeightChangedEvent


and this is how it works:
B4X:
    'Library zum Einblenden/Ausblenden der Tastatur.
    ime1.Initialize("ime1")
    ime1.AddHeightChangedEvent

    sm.Initialize("sm")
    Dim offset As Int = 30%x
    sm.BehindOffset = offset
    sm.Mode = sm.LEFT
    Dim lftMenu As Panel
    lftMenu.Initialize("")
    sm.Menu.AddView(lftMenu, 0, 0, 100%x - offset, 100%y)
    lftMenu.LoadLayout("frmMenu")
 
Upvote 0
Top