1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question Customlistview Itemclick

Discussion in 'Android Questions' started by dagodom, Jul 7, 2019.

  1. dagodom

    dagodom Member Licensed User

    I'm probably losing myself in a glass of water.
    Using customlistview to show a list of texts, each panel added to the customlistview therefore has a text field.
    For each panel I have associated a unique code that allows you to select the record associated with the text and then perform operations on it.
    ItemClick associated with the customview is not activated because the panel is completely "covered" by the edittext field.
    So I can't capture the itemclick event on customlistview.
    Is there a javascript-type "click through" mechanism to "activate" the custom list view item?

    Code:
    Sub b_4_click

        s_panel_message.AddView(s_panel_message_sal.AsView,  
    0,0,100%x100%y)
        
    Dim Cursor1 As Cursor
        
    Dim p_tmp As Panel
        
    Dim stmp As String
        Cursor1 = 
    SQL.ExecQuery("select rowid, * from na_msgoff ")
        
    For i = 0 To Cursor1.RowCount - 1
            Cursor1.Position = i
            stmp = Cursor1.GetString(
    "mo_msg")
            p_tmp = addmessage(stmp)
            s_panel_message_sal.Add(p_tmp, p_tmp.height, Cursor1.GetString(
    "rowid"))
        
    Next
        p_tmp = s_panel_message_empty
        s_panel_message_sal.Add(p_tmp, p_tmp.height, 
    "")
    End Sub

    Sub addmessage(vmsg As StringAs Panel

        
    Dim p_tmp As Panel
        
    Dim str1 As EditText
        p_tmp.Initialize(
    "")
        p_tmp.Color =  
    Colors.RGB(23515115)
        
        str1.Initialize(
    "str1")
        str1.Color = 
    Colors.Red
        str1.TextColor = 
    Colors.White
        str1.Gravity = 
    Gravity.TOP + Gravity.LEFT
        str1.width = objwidth
        str1.Height = 
    150dip
        str1.text = vmsg
        str1.Enabled = 
    False
        p_tmp.AddView(str1,leftstart,
    10dip,t_1.width, t_1.Height)
        p_tmp.height = str1.Height + lspace
        
    Return p_tmp
    End Sub

    Sub s_panel_message_sal_ItemClick (Index As Int, Value As Object)
       
    log(Index)
    End Sub
     
  2. mangojack

    mangojack Well-Known Member Licensed User

    One option ... add another transparent panel covering the edit text to handle the click event.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    The EditText will catch the touch events. Why are you using an EditText instead of Label? Is the user expected to edit the text?

    Maybe put a button or CheckBox on the left side instead of handling the ItemClick event.

    BTW, it is a mistake to create the layout programmatically. It will be easier to do it with the designer. Especially when it becomes more complicated.
     
  4. dagodom

    dagodom Member Licensed User

    Thank you.
    Yes, after the selection the user can modify the text (after having recovered some information from the DB).
    I tried to capture the click on the edittext, but the subroutine str1_click is not activated, also since they are all equal fields I don't know how to distinguish them, that is how to recover the id of access to the DB.
    If I put a button or a checkbox anyway I have to distinguish each single edittext and have the click subroutine for each edittext.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    It should be simple to distinguish between the items with CLV.GetItemFromView.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice