Android Question ListView Items Scroll In Loop

ronovar

Active Member
Licensed User
Longtime User
I im generating listview items with json:

B4X:
For Each Genre As List In Main.VideoClubItems
        'ADD - VideoClub Genre
        lvVideoClub.AddSingleLine2(" "&Genre.Get(1), Genre.Get(0))
Next

So i have in listview this order of 6 items visible on the screen...and this works very good..now i need to make when user using remote control press down button and last item is activated to scroll down and when last item is selected in listview to get at the beggining of array and show first item and so on...best is the example:

I have generated using above code listview items:

Item1
Item2
Item3
Item4
Item5
Item6

And i have 9 items added using above code so when i get to last item:

Item4
Item5
Item6
Item7
Item8
Item9

I need to get this from beggining:

Item5
Item6
Item7
Item8
Item9
Item1

Then:

Item6
Item7
Item8
Item9
Item1
Item2

And so on..so how can i make this in B4A? So when last item in listview is selected go from first item so when i scroll down or up i get all items in listview (so i don't need to scrool up if i im at last item in listview)...How do i need to write so nice feauture?
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
You're probably looking for something like this -> A new WheelView.

There are plenty of other examples too - search the forum for "Wheel View"...

- Colin.
 
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
I have this in javascript that do what i need:

B4X:
/* MENU - loop function */
        var MenuList = function(direction) {
        mnu += direction + menu.length;
        mnu %= menu.length;
        var arr = menu.concat(menu).slice(mnu, mnu + 3); }

So i try to rewrote this function in B4A but i could not get result i get always error message OutOfBounds:

B4X:
'SET - MenuList Shift
Sub MenuList(Direction As Int)
    mnuCounter = mnuCounter + Direction + mnuItems.Length
    mnuCounter = mnuCounter Mod mnuItems.Length
    
    Dim BC As ByteConverter
    Dim mnuMenu() As String
    BC.ArrayCopy(mnuItems, 0, mnuMenu, 0, mnuCounter + 3)
    Log(mnuMenu)
End Sub

And my declarations:

B4X:
'DEFINE - Menus
    Dim mnuCounter As Int = -1
    Dim mnuItems() As String = Array As String("AA", "BB", "CC", "DD")

So how i don't know how to write in B4A following line:
B4X:
var arr = menu.concat(menu).slice(mnu, mnu + 3);

I try using:

B4X:
BC.ArrayCopy(mnuItems, 0, mnuMenu, 0, mnuCounter + 3)

But i im working with strings array not bytes array...so how can this function needs to be rewritte to return same result as above in javascript that works very well.
 
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
It is nor related directly..but using array shift and removing first three places i can then remove listview items to screen and add new one..so it will scroll in loop...so how is possible in b4a to write this function that works in javascrtipt?

B4X:
var arr = menu.concat(menu).slice(mnu, mnu + 3);

Then i can do with for loop to generate listview items.

Thanks.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is nor related directly..but using array shift and removing first three places i can then remove listview items to screen and add new one..so it will scroll in loop...so how is possible in b4a to write this function that works in javascrtipt?
Quite simple. But it should be discussed in its own thread as it is not directly related to ListView.
 
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
Ok..could you please move this question to thread that it belongs and replay with b4a code? Thanks.
 
Upvote 0
Top