B4A Library SD: Panel Extra (Slide Swap Scroll)

Star-Dust

Expert
Licensed User
hi Star-Dust it is possible that each lower button can load a different activity. the problem is that the whole code becomes very extensive
You can make each button make a panel visible or start a specific activity. You can make it with the Library as it is, it doesn't need to be modified.

I can't make you an example right now, I'm too busy, but you can do it by yourself.
 

Carlos marin

Active Member
Licensed User
You can make each button make a panel visible or start a specific activity. You can make it with the Library as it is, it doesn't need to be modified.

I can't make you an example right now, I'm too busy, but you can do it by yourself.
I have worked with panels and loaded activities on them, but I do not know if it is possible to work the slide swap in different activities so I would not have all the code in one activity
 

Star-Dust

Expert
Licensed User
you can divide the code into classes or into custom views. but I don't know the App so I can't give you specific advice
 

SMOOTSARA

Active Member
Licensed User
Example Panel Navigator

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private PanelNavigator1 As PanelNavigator
    Dim Color() As Int = Array As Int(0xffffffff,0xffc1ffbf,0xff009699,0xffcd1515,0xffa786ee)
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("panelMain")

    For i=0 To 4
        PanelNavigator1.Add(i,Color(i),LoadBitmap(File.DirAssets,(i+1) & ".png"))
    Next

    PanelNavigator1.Add("Name 5",Colors.Blue,Null)
    ' Also
    ' PanelNavigator1.Add2("Name 5",Colors.Blue,Null).LoadLayout("mypanel")
    ' Or
    ' Dim I as int = PanelNavigator1.Add("Name 5",Colors.Blue,Null)
     ' PanelNavigator1.GetPanel(I).LoadLayout("mypanel")

    Dim L As Label
    L.Initialize("")
    L.Gravity=Gravity.CENTER
    L.Text="First Panel"
    L.TextColor=Colors.Black
    L.TextSize=20
    ' Find first panel and Add a Label
    PanelNavigator1.GetPanel(0).AddView(L,0,0,100%x,40dip)
End Sub

Example TitleScroll
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    TitleScrollView1.MyTitleReduced.LoadLayout("reduced")
    TitleScrollView1.MyTitleFull.LoadLayout("full")
    TitleScrollView1.Scroll.Color=Colors.Yellow
    For i= 1 To 30
        Dim Label1 As Label
   
        Label1.Initialize("")
        Label1.Text="Item " & I
        Label1.Textcolor=Colors.Black
   
        TitleScrollView1.Scroll.AddView(Label1,0,(i-1)*40dip,100%x,40dip)
        TitleScrollView1.Scroll.Height=i * 40dip
    Next

End Sub


hi Star-Dust 🌹

How do I add "PanelNavigator" to a "ScrollView"?

I want to add "PanelNavigator" to the "ScrollView" as a Custom View (without the use of layout in designer)

B4X:
Sub Activity_Create(FirstTime As Boolean)
    
    Dim ScrollView_master As ScrollView
    ScrollView_master.Initialize(200%y)
    ScrollView_master.Color=Colors.Red
    ScrollView_master.Panel.Color=Colors.DarkGray
    
    Activity.AddView(ScrollView_master,2%x,2%y,96%x,96%y)   
    
''''    ScrollView_master.panel.LoadLayout("panelMain")

    Private PanelNavigator1 As PanelNavigator
    PanelNavigator1.Initialize(Me,"PanelNavigator1")
    ScrollView_master.panel.AddView(PanelNavigator1.GetBase,0,0,80%x,40%y)

    
    For i=0 To 50
        PanelNavigator1.Add(i,Colors.ARGB(255,Rnd(0,255),Rnd(0,255),Rnd(0,255)),Null)
        PanelNavigator1.SetIconPanelVisible(False)
    Next


End Sub
but error is:

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 39 (Main)
java.lang.RuntimeException: Object should first be initialized (Panel).
Did you forget to call Activity.LoadLayout?
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at b4a.example.main._activity_create(main.java:408)
    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:348)
    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:6680)
    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 **

thanks
 

DonManfred

Expert
Licensed User
without the use of layout in designer
The correct way of adding a customview is by using the Designer.
You can create a single layout with the customtype and load the layout to the scrollview whenever you need one.

Away from that it is suggested to us xCLV as it is a ScrollView with eXtended Features.
 

Star-Dust

Expert
Licensed User
hi Star-Dust 🌹

How do I add "PanelNavigator" to a "ScrollView"?

I want to add "PanelNavigator" to the "ScrollView" as a Custom View (without the use of layout in designer)

B4X:
Sub Activity_Create(FirstTime As Boolean)

    Dim ScrollView_master As ScrollView
    ScrollView_master.Initialize(200%y)
    ScrollView_master.Color=Colors.Red
    ScrollView_master.Panel.Color=Colors.DarkGray

    Activity.AddView(ScrollView_master,2%x,2%y,96%x,96%y)

''''    ScrollView_master.panel.LoadLayout("panelMain")

    Private PanelNavigator1 As PanelNavigator
    PanelNavigator1.Initialize(Me,"PanelNavigator1")
    ScrollView_master.panel.AddView(PanelNavigator1.GetBase,0,0,80%x,40%y)


    For i=0 To 50
        PanelNavigator1.Add(i,Colors.ARGB(255,Rnd(0,255),Rnd(0,255),Rnd(0,255)),Null)
        PanelNavigator1.SetIconPanelVisible(False)
    Next


End Sub
but error is:

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 39 (Main)
java.lang.RuntimeException: Object should first be initialized (Panel).
Did you forget to call Activity.LoadLayout?
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at b4a.example.main._activity_create(main.java:408)
    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:348)
    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:6680)
    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 **
thanks
Actually putting a PanelNavigator inside a scroll View is a strange and difficult solution to manage. Think only of the management of Event raised. They will all be absorbed by PanelNavigator and ScrollView would not function properly.

Having said that, as @DonManfred has told you, you must create a Layout to design and insert a PanelNavigator inside a Panel. You can insert this panel in ScrollView.

Or you have to initialize PanelNavigator and call DesignerCreateView, so that mBase is generated, otherwise it is not initialized and generates that error.

PanelNavigator is designed to be hooked on Activity, I suggest you think of a better solution for this type of view you want to achieve
 
Last edited:

Zlgo

Member
Hi!
I just try your SlidingDemo and at beginning is Messageshow with "Demo remaining x days" , so is this limited library?
 

Star-Dust

Expert
Licensed User
Hi!
I just try your SlidingDemo and at beginning is Messageshow with "Demo remaining x days" , so is this limited library?
Hi,
This library is in a limited version, some classes will only run one week to allow testing. You can receive the full version by making a donation.
 
Last edited:
Top