Android Question Error in Activity.addview

Espinosa4

Active Member
Licensed User
Longtime User
Happy New Year everyone!
I'm having problems when I'm trying to add a view into in activity.

Here the code.
B4X:
ub CambioInicial_click   
    Dim Servicio As InputDialog
    Dim R2 As Phone   
    
    Activity.CloseMenu
    Dim sss As String
    Prefijo = ""
    Main.Preguntar = False
    If Servicio.Show("Introduce el primer servicio (Añade una R después del número de servicio para indicar que son Reducidos)","VER+","Aceptar","Cancelar","",Null) = DialogResponse.POSITIVE Then
        R2.HideKeyboard(Activity)
        If Servicio.Input.Length = 0 Then
            Msgbox("Debes indicar un servicio válido. Sólo el número","Error")
            Return   
        End If
        If Servicio.Input.Length = 1 Then
            sss = Servicio.Input
        Else
            If IsNumber(Servicio.Input) = False Then
                sss = Servicio.Input.SubString2(0,Servicio.Input.Length-1)
            Else
                sss = Servicio.Input.SubString2(0,Servicio.Input.Length)
            End If
        End If
        Log(sss)
        If IsNumber(sss) = False Then
            Msgbox("Debes indicar un servicio válido. Sólo el número","Error")
            Return
        Else
            If Servicio.Input.EndsWith("R") = True Or Servicio.Input.EndsWith("r") Then Prefijo = "r"
            NumSer = sss
        End If
    Else
        Return
        R2.HideKeyboard(Activity)
    End If
    R2.HideKeyboard(Activity)
    height = CalculateHeight(True, False)
    vp.Panels(0).RemoveView
    vp.Panels(1).RemoveView
    vp.Panels(2).RemoveView
    vp.Panels(3).RemoveView
    vp.Panels(4).RemoveView
    vp.Panels(5).RemoveView
    vp.Panels(6).RemoveView
    vp.Panels(7).RemoveView
    vp.Panels(8).RemoveView
    vp.Initialize("vp",9, 100%x,height)
    'vp.Initialize("vp",9, 100%x,height)
    Activity.AddView(vp.AsView, 0, 0, 100%x, height)
    'load the pages layouts
    AsignarServicios(Prefijo,NumSer)
    vp.Panels(0).LoadLayout("LytImagen2")
    vp.Panels(1).LoadLayout("LytImagen2")
    vp.Panels(2).LoadLayout("LytImagen2")
    vp.Panels(3).LoadLayout("LytImagen2")
    vp.Panels(4).LoadLayout("LytImagen2")
    vp.Panels(5).LoadLayout("LytImagen2")
    vp.Panels(6).LoadLayout("LytImagen2")
    vp.Panels(7).LoadLayout("LytImagen2")
    vp.Panels(8).LoadLayout("LytImagen2")
    bar.RemoveTabs
    bar.Initialize("bar")
    'bar.Icon = LoadBitmap(File.DirAssets, "ic_action_user.png")
    bar.NavigationMode = bar.NAVIGATION_MODE_TABS
    bar.AddTab(sNombres(0))
    bar.AddTab(sNombres(1))
    bar.AddTab(sNombres(2))
    bar.AddTab(sNombres(3))
    bar.AddTab(sNombres(4))
    bar.AddTab(sNombres(5))
    bar.AddTab(sNombres(6))
    bar.AddTab(sNombres(7))
    bar.AddTab(sNombres(8))
    bar.ShowUpIndicator = False
    bar.SelectedIndex = currentPage
    Activity.Title = "VER+"
    bar.Subtitle = "SERVICIOS"
    'Activity.AddMenuItem("Cambiar número de servicio inicial","CambioInicial")
End Sub

The program give me an error but undefinied.
Here the error...



java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/ViewPager;
at anywheresoftware.b4a.objects.StdActionBar$StdViewPager.Initialize(StdActionBar.java:349)
at www.l4pro.tranvia.actimagen2._activity_create(actimagen2.java:510)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
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 www.l4pro.tranvia.actimagen2.afterFirstLayout(actimagen2.java:105)
at www.l4pro.tranvia.actimagen2.access$000(actimagen2.java:17)
at www.l4pro.tranvia.actimagen2$WaitForLayout.run(actimagen2.java:83)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7840)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:985)
Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager
... 18 more
** Activity (actimagen2) Resume **


Any idea what I doing wrong.
(This code worked always. I don't know if it is caused by a new librery version or something like that)

Thanks you very much indeed in advance!
 

Espinosa4

Active Member
Licensed User
Longtime User
Code with Msgbox = broken code.

Download the StdActionBar library again. I've jetified it and it will now work with AndroidX sdk. Note that you can also do it yourself with Tools - Jetifier.
Once again thank you very much indeed Erel for your help!

Cheers
 
Upvote 0
Top