Android Question ULV properties

FrankDev

Active Member
Licensed User
Longtime User
First:

sorry for my bad english.

i have a Ulv-List with 50 rows.
at start i want to select first row (maybe other Background (Color))

i use fire TV remote
if i press down Key (KeyCode = 20) then next row shold be selected,

usw..

regards Frank
 

MarcoRome

Expert
Licensed User
Longtime User
First:

sorry for my bad english.

i have a Ulv-List with 50 rows.
at start i want to select first row (maybe other Background (Color))

i use fire TV remote
if i press down Key (KeyCode = 20) then next row shold be selected,

usw..

regards Frank

You ca search THIS or look this THREAD.
In library ULV you have example and documentation.
 
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
Hi Marco

maybe your right.
i tried a lot of examples, read a lot of text.
but I do not get ahead.

have solved so many problems
but now I'm stuck
for many hours :(

maybe it is so easy
can anyone help me donate for 20 Euro ?

regards Frank
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi Frank you can use this:

B4X:
'Adds an ULV to the activity
ULV.Initialize(0, 0, "", "ULV")
ULV.Color = Colors.White
ULV.SelectionMode = ULV.SELECTION_SINGLE '<---- This is for select Single Row
Activity.AddView(ULV, 0, 0, 100%x, 100%y)
....


Sub Item_ContentFiller(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)
'Sets the text of the label
If ULV.IsSelected(Position) Then
'The selected rows are green
LayoutPanel.Color = Colors.Green '<---- This if you select row is GREEN
Else
'Alternatively, the rows are coloured in white or in light gray
If Position Mod 2 = 0 Then
LayoutPanel.Color = Colors.White
Else
LayoutPanel.Color = Colors.LightGray
End If
End If
.....

if Keycode = Keycodes..... then
i = i + 1
ULV.JumpTo(i,True) '<--- This is for jump in position that you want
ULV.SetSelected(i, True) '<--- This is for colour ( as you tap about row, Select row )
End If
 
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
hi Marco

will not work.
list is shown White / light gray
if i klick (keycode 20) nothing happened.
if i reach end of list..
list scrolls fast and every item ist green.. ?!?
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
This is movie:


This is full code:

B4X:
Sub Globals
    Dim ULV As UltimateListView
    Dim Fruits As List
    Dim ItemHeight As Int = 60dip
    Dim i As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Creates a list of fruits
    Fruits.Initialize2(Array As String("Apple", "Banana", "Cherry", "Coconut", "Grapes", "Lemon", "Mango", "Melon", "Orange", "Pear", "Pineapple", "Strawberry"))

    Activity.AddMenuItem("First", "First")

    'Adds an ULV to the activity
    ULV.Initialize(0, 0, "", "ULV")
    ULV.Color = Colors.White
    ULV.SelectionMode = ULV.SELECTION_SINGLE
    Activity.AddView(ULV, 0, 0, 100%x, 100%y)

    'Creates a layout to display the fruit name and builds the items list (1 item = 1 fruit)
    ULV.AddLayout("FRUIT_NAME", "Item_LayoutCreator", "Item_ContentFiller", ItemHeight, True)
    ULV.BulkAddItems(Fruits.Size, "FRUIT_NAME", 0)
  
    ULV.SetSelected(0, True)

End Sub

Sub First_Click
    i = i + 1
    ULV.JumpTo(i,True)
    ULV.SetSelected(i, True)


End Sub



Sub Activity_Resume
End Sub

Sub Activity_Pause(UserClosed As Boolean)
End Sub

Sub Item_LayoutCreator(LayoutName As String, LayoutPanel As Panel)
    'Very simple layout: just a label
    LayoutPanel.LoadLayout("fruitlabel")
End Sub

Sub Item_ContentFiller(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)
    'Sets the text of the label
    If ULV.IsSelected(Position) Then
        'The selected rows are green
        LayoutPanel.Color = Colors.Green
    Else
        'Alternatively, the rows are coloured in white or in light gray
        If Position Mod 2 = 0 Then
            LayoutPanel.Color = Colors.White
        Else
            LayoutPanel.Color = Colors.LightGray
        End If
    End If
  
  
    Dim lbl As Label = LayoutPanel.GetView(0) 'First (and only) view in the panel
    lbl.Text = Fruits.Get(Position)
End Sub

 
Last edited:
Upvote 0
Top