Android Question AHSwipeToRefresh library with XCustomListView Error (Solved)

Discussion in 'Android Questions' started by A0_2_A7, May 3, 2019.

  1. A0_2_A7

    A0_2_A7 Member Licensed User

    Hi, i'm trying to use the AHSwipeToRefresh library with XCustomListView but it gives me the following error. Is there any way to use this fantastic library with XCustomListView?

    Code:
    *** Service (starter) Create ***
    ** 
    Service (starter) Start **
    ** 
    Activity (main) Create, isFirst = true **
    Error occurred on line: 
    39 (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:5034)
        at android.view.ViewGroup.addView(ViewGroup.java:
    4865)
        at android.view.ViewGroup.addView(ViewGroup.java:
    4805)
        at android.view.ViewGroup.addView(ViewGroup.java:
    4778)
        at de.amberhome.strefresh.AHSwipeToRefresh.AddView(AHSwipeToRefresh.java:
    97)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.shell.Shell.runVoidMethod(
    Shell.java:777)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:354)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:255)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    144)
        at b4a.example.main.afterFirstLayout(main.java:
    104)
        at b4a.example.main.access$
    000(main.java:17)
        at b4a.example.main$WaitForLayout.run(main.java:
    82)
        at android.os.Handler.handleCallback(Handler.java:
    873)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    193)
        at android.app.ActivityThread.main(ActivityThread.java:
    6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    858)
    ** 
    Activity (main) Resume **
     

    Attached Files:

  2. A0_2_A7

    A0_2_A7 Member Licensed User

    Ok, the solution was to remove the view of the activity before.

    Code:
    'It is not possible to add child objects to custom views in the designer.
        'So we have to add the listview manually here.
        RemoveView(CustomListView1.AsView)
        STR.AddView(CustomListView1.AsView)
    call this sub:

    Code:
    Sub RemoveView (V As View)
        
    For i = 0 To Activity.NumberOfViews - 1
            
    If Activity.GetView(i) = V Then
                
    Activity.RemoveViewAt(i)
                
    Exit
            
    End If
        
    Next
    End Sub
    I upload the corrected project.

    Regards.
     

    Attached Files:

    José J. Aguilar likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice