Android Question UltimateListView change label text by button click

Alexander Stolte

Expert
Licensed User
Longtime User
Hey Community,

I create a list with the UltimateListView and fill the list with my layout, on this layout are 3 Buttons and any labels.

Here a small section:
button on layout.PNG

How can i give the first label +1 when i press the smylie? the Smylie is an Button.

I've tried it, but do not come any further:

B4X:
Sub ulv_ItemClick(ItemID As Long, Position As Int, ClickedPanel As Panel)
    'Log(ItemID)
   Dim pnl_main As Panel = ClickedPanel.GetView(0)
    Dim btn_up As Button = pnl_main.GetView(6)
    Dim lbl_counter As Label = pnl_main.GetView(5)
   
    'if counting = 1 Then
        'opo = lbl_counter.Text
        'ToastMessageShow(opo, True)
        'lbl_counter.Text = opo +1
        'counting = 0
    'End If
'    counting = lbl_counter
    'Log(btn_up.)
   
   
End Sub

Thanks for help!
 

Alexander Stolte

Expert
Licensed User
Longtime User
In the documentation is the following:
USER ACTIONS Events: CellClick, CellLongClick, CellTouch, ItemClick, ItemLongClick, ItemTouch, Touch A click on an item will fire a CellClick or an ItemClick event depending on the layout of the item (a row layout with cells will fire a Cell... event). To handle a click on a specific view, use the Click event of the view, as usual. To know the ID of the item containing the clicked view, you have two solutions: storing the item ID in the Tag property of the view or calling FindIDInVisibleItems with the sender of the event. If you want to perform an operation for a clicked view based on the content of another view, you can either read the underlying data of the other view or store the reference of this latter view in the Tag property of the view that will receive the Click event. The need for the Touch event is very limited. You can use it to detect custom gestures or to block the Touch events (by returning True) without disabling the list.

Does anyone have an example, how the code looks like?
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
i dont use maps.

B4X:
Sub clv2_LayoutCreator(LayoutName As String, LayoutPanel As Panel)
    LayoutPanel.LoadLayout("frm_mainlayout")
End Sub

Sub clv2_ContentFiller(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)
    Dim Panel1 As Panel = LayoutPanel.GetView(0)
    Dim lbl_content As Label = Panel1.GetView(0)
    lbl_content.Text = "Nur mit Seil und Haken gesichert auf einem schmalen Grat balancieren."

Sub clv2_ItemClick(ItemID As Long, Position As Int, ClickedPanel As Panel)
'    Log(ItemID)
'  
    Dim pnl_main As Panel = ClickedPanel.GetView(0)
    Dim btn_up As Button = pnl_main.GetView(6)
  
    btn_up.Tag = btn_up
    ToastMessageShow(btn_up.Tag, True)
  
    Dim lbl_counter As Label = pnl_main.GetView(5)
'btn_up.Tag = clv2.
'ToastMessageShow(ItemID, True)

    'if counting = 1 Then
'        opo = lbl_counter.Text
'        ToastMessageShow(opo, True)
'        lbl_counter.Text = opo +1
'        counting = 0
    'End If
'    counting = lbl_counter
    'Log(btn_up.)
  
    'ToastMessageShow( clv2.GetItemID(Position), True)
End Sub

Sub clv2_ItemSelectedStateChanged(ItemID As Long, Position As Int, Selected As Boolean)
    'Log("SelectionChanged ID=" & ItemID & ", Pos=" & Position & ", Selected=" & Selected)
  
  
End Sub





Sub btn_up_Click
'Dim Index As String = Sender
'Log("Index: " & Index)

Dim b As Button = Sender
ToastMessageShow(b, True)
'Log("Button: " & b)
'ToastMessageShow(counting, True)
'Dim btn_up As Button = Sender
'Dim ID As Int =  btn_up.Tag
'ToastMessageShow(ID, True)
  
  

    counting = 1
End Sub
End Sub

I load a Layout from the designer, on this layout are the labels and buttons.
layout.PNG


If i press "btn_up" should on "lbl_counter" +1
I have no idea, because I do not know how I get the ID of the button in the "btn_click" event to then change the label.
 
Upvote 0
Top