B4A Library [Class] Multi Type SlidingPanels

[Class/Library] Multi Type SlidingPanels

I wanted to make one SlidingPanels that it could be used in multiple ways. Now that I have finished writing the code I put at your disposal.

At the moment you can do these variants SlidingPanels:

- Classic full screen mode.
- Sliding panels with smaller screen.
- Sliding panels with smaller screen and with zoom!
- With or without friction.

Methods:
- Click.
- Change.

Methods:
- JumpToPanel () - Runs the SlidingPanels up to a specific Panel.
- GetCurrentPanel - Returns the number of the current Panel.
- GetSlidingInProgress - Return if the SlidingPaneles is in progress.
- SetSpeedScroll () - Sets the speed of sliding.

It is possible to easily create a page counter thanks to the events.

[UPDATE V1.10]
- Added the ability to use the touch events of Activity, which is useful when you must insert many objects on the panels. Recommended this mode.
- Added the field area to be used for zooming.

[UPDATE V1.10a]
- Minor bug fix for small display.

[UPDATE V1.20]
- Added the LongClick event.
- Changed the type of data sent with the Click events and LongClick.
- Minor improvements.

[UPDATE V1.21]
- Bugfix in FullScreen mode (loop setup).

IMPORTANT
For most fluidity add this code to the Manifest:
B4X:
SetActivityAttribute(Main, android:hardwareAccelerated, "true")

For suggestions and bug reports please do not hesitate to post it here.
 

Attachments

  • Screenshot_2012-11-14-18-22-53 (ridotta).jpg
    Screenshot_2012-11-14-18-22-53 (ridotta).jpg
    11.4 KB · Views: 2,258
  • Screenshot_2012-11-14-18-23-10 (ridotta).jpg
    Screenshot_2012-11-14-18-23-10 (ridotta).jpg
    13.3 KB · Views: 2,136
  • Screenshot_2012-11-14-18-24-18 (ridotta).jpg
    Screenshot_2012-11-14-18-24-18 (ridotta).jpg
    33.7 KB · Views: 2,158
  • Screenshot_2012-11-15-10-02-38 (ridotta).png
    Screenshot_2012-11-15-10-02-38 (ridotta).png
    18.7 KB · Views: 1,907
  • SlidingPanels_1.21.zip
    69.1 KB · Views: 1,215
Last edited:

rafaelbr20

Member
Licensed User
Longtime User
You have to use the click event of the panel in place of the image.
If the image is smaller than the panel you have to check the XY coordinates if coincide with the image. This control is very simple to do.

Perfect Dominex ! Thanks for your help !

I´ll try to do it !

Best Regards !

Rafael
 

lucdrb

Active Member
Licensed User
Longtime User
Hi Dominex,

I've just see your class and it's look very nice and easy.:)
In your example you slide the panels from right to left and left to right, is it a way to slide the panels from top to bottom and bottom to top?

Thank in advance for your andwer.

Luc
 

luke2012

Well-Known Member
Licensed User
Longtime User
[Class/Library] Multi Type SlidingPanels

I wanted to make one SlidingPanels that it could be used in multiple ways. Now that I have finished writing the code I put at your disposal.

At the moment you can do these variants SlidingPanels:

- Classic full screen mode.
- Sliding panels with smaller screen.
- Sliding panels with smaller screen and with zoom!
- With or without friction.

Methods:
- Click.
- Change.

Methods:
- JumpToPanel () - Runs the SlidingPanels up to a specific Panel.
- GetCurrentPanel - Returns the number of the current Panel.
- GetSlidingInProgress - Return if the SlidingPaneles is in progress.
- SetSpeedScroll () - Sets the speed of sliding.

It is possible to easily create a page counter thanks to the events.

[UPDATE V1.10]
- Added the ability to use the touch events of Activity, which is useful when you must insert many objects on the panels. Recommended this mode.
- Added the field area to be used for zooming.

[UPDATE V1.10a]
- Minor bug fix for small display.

[UPDATE V1.20]
- Added the LongClick event.
- Changed the type of data sent with the Click events and LongClick.
- Minor improvements.

[UPDATE V1.21]
- Bugfix in FullScreen mode (loop setup).

IMPORTANT
For most fluidity add this code to the Manifest:
B4X:
SetActivityAttribute(Main, android:hardwareAccelerated, "true")

For suggestions and bug reports please do not hesitate to post it here.
@Dominex prima di tutto complimenti per la tua "Classe" :)
Vorrei chiederti un consiglio (visto la tua esperienza sullo slide) su come implementare una sorta di slide in e slide out di pannelli in verticale.
Cerco di spiegarmi meglio :

Praticamente avrei 2 panels, uno solo visibile, e l'altro nascosto e praticamente a fronte di un certo evento sul primo vorrei far "sparire" il pannello visibile con un effetto slide e far apparire l'altro pannello nascosto sempre con effetto slide (pensavo verticale).
 

Dominex

Active Member
Licensed User
Longtime User
@luke2012
Ti ringrazio. ;)

Credo di aver capito di cosa hai bisogno. Io ti consiglio di fare lo slide con la libreria Animation, sarebbe molto semplice e funzionale da fare, una volta che l'evento viene innescato fai partire l'animazione in qualunque direzione desideri.
 

Clayton

Member
Licensed User
Longtime User
Ciao classe complimenti , ho provato ad usarlo con

SD ( i) .Initialize ( " SD " , 300 , Attività , Me , False) ' inizializzare la classe .

Mettere in attività ho trascorso una ScrollViewer

restituisce errore.
>>>can host only one direct child

Avete delle soluzioni?
 

Dominex

Active Member
Licensed User
Longtime User
Ciao classe complimenti , ho provato ad usarlo con

SD ( i) .Initialize ( " SD " , 300 , Attività , Me , False) ' inizializzare la classe .

Mettere in attività ho trascorso una ScrollViewer

restituisce errore.
>>>can host only one direct child

Avete delle soluzioni?
Dopo aver inizializzato la classe occorre definire il tipo di sliding, ModeFullSreen ecc.
 

Clayton

Member
Licensed User
Longtime User
B4X:
Dim vScroll As ScrollView
    Dim Panels As Panel
    Dim nReg As Int
    Dim P_Width As Int
    Dim P_Height As Int
    Dim P_Top As Int

    Dim i,c As Int
    Activity.Title  = "Backups"
    Activity.Color= Colors.LightGray
   
    'Create Scroll   
    vScroll.Initialize(1000dip)
    vScroll.Color= Colors.Green
    vScroll.Panel.Height = 200dip * 10 'Set Size Panel Scroll
    Activity.AddView (vScroll,0,0,100%x,100%y)
   

    nReg = 3 'Number Panel Horizontal
    P_Width = 100%x ' Set Width Painel
    P_Height = 220dip 'Set Heigth Painel
   
   
    For i = 0 To 2
       
        SD(i).Initialize("SD",300,vScroll ,Me,False) 'Initialize the Class.
       
        If i = 0 Then P_Top = 120dip 'Set Top Slid 1
        If i = 1 Then P_Top = 270dip 'Set Top Slid 2   
        If i = 2 Then P_Top = 420dip 'Set Top Slid 3
   
        SD(i).ModeLittlePanels(nReg,P_Width ,P_Height ,P_Top,0%x,False)
       
       
        '---Add elements to Panels---
        For c = 0 To SD(i).Panels.Length-1
            Panels.Initialize("panels")
            Panels.Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255))
       
       
        '-- LABEL
        Dim lbl_Data As Label
        lbl_Data.Initialize("")
        lbl_Data.TextColor = Colors.White
        lbl_Data.TextSize = 14
        lbl_Data.Text =  "HOJE " & i
        lbl_Data.Gravity = Gravity.CENTER_HORIZONTAL
        lbl_Data.Typeface =Typeface.DEFAULT_BOLD
        Panels.AddView(lbl_Data, 0  , 10dip, 100%x, 30dip)
        '-- FIM DA NUMERACAO DAS PAGINAS
       
        SD(i).Panels(c).AddView(Panels,0,75dip,SD(i).Panels(c).Width,SD(i).Panels(c).Height)

        Next
        SD(i).Start(0) 'Start the SlidingPanels.
       
    Next


Quando fate un passo su un codice Panel
SD (i) .Initialize ("SD", 300, PANEL, Me, False) 'inizializzare la classe. = funziona

ma quando ho
SD (i) .Initialize ("SD", 300, VScroll, Me, False) 'inizializzare la classe. = Non riesce

per favore mi puoi dire dove l'errore è.
 

GaNdAlF89

Active Member
Licensed User
Longtime User
@Dominex
Thanks! (Sono anch'io italiano :))
Uso questa classe per mostrare alcune foto in base al luogo che l'utente sceglie da una lista. Il mio problema è però che a volte un luogo ha solo una foto: la classe funziona ma se provo a scorrere l'unico pannello (che contiene la foto) verso sinistra è come se ci fosse un secondo pannello; ciò genera un'eccezione (che gestisco) ma il pannello rimane centrato sul secondo, come se questo esistesse (e come dicevo è vuoto), o equivalentemente, il primo pannello rimane fermo a sinistra. Come posso risolvere in questo caso? Grazie mille e complimenti!

I use SlidingPanels to show some photo based on a location selected by user. But when a location has only a photo, and the user tries to slide to the next panel (that doesn't exist), the second panel is shown anyway (without photo); I catch this exception but the current panel remains to second panel (the first is on the left).
How can I fix this? Thanks
 

Dominex

Active Member
Licensed User
Longtime User
Scusa se rispondo solo ora, ma purtroppo ho il PC in assistenza e non posso quindi nemmeno provare quando hai detto.
Prova a inserire un check nella touch event della classe interrogando se c'è più di un panel, se sì fai Return, così esci e non il panel non si muoverà.

Sorry if I answer only now, but unfortunately I have the PC in assistance and I can not even try when you said.
Try to put a check in the touch event class questioning if there is more than one panel, so if you do return, so the panel will not move.
 

GaNdAlF89

Active Member
Licensed User
Longtime User
Scusa se rispondo solo ora, ma purtroppo ho il PC in assistenza e non posso quindi nemmeno provare quando hai detto.
Prova a inserire un check nella touch event della classe interrogando se c'è più di un panel, se sì fai Return, così esci e non il panel non si muoverà.

Sorry if I answer only now, but unfortunately I have the PC in assistance and I can not even try when you said.
Try to put a check in the touch event class questioning if there is more than one panel, so if you do return, so the panel will not move.
I tried this, but it doesn't work. I solved my problem by catching this exception in the _Change event and forcing a JumpToPanel to (CurrentPanel-1). Thanks anyway!
 

Prosg

Active Member
Licensed User
Longtime User
Hello Dominex,

how can i add a Page indicator for the panels?



regards
 
Last edited:
Top