Android Question How to capture click event of a label placed on a CustomListView

Discussion in 'Android Questions' started by Anser, Jul 30, 2015.

  1. Anser

    Anser Active Member Licensed User

    Friends,

    How do I capture the click event of a label placed on the panel inside a CustomListView.

    I have a panel containing several labels on it, the panel is added to the CustomListView. One of the label contains the mobile number. I need to capture the click event of this particular label, unfortunately the click event is handled by the CustomListView.

    I don't know, how to capture the click event of the label

    Any help will be appreciated.

    The sample code

    Code:
    #Region  Activity Attributes
        
    #FullScreen: False
        
    #IncludeTitle: True
    #End Region
    #Extends: android.support.v7.app.ActionBarActivity

    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.

    End Sub

    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.

        
    Private clvCallDetails As CustomListView

    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        Activity.LoadLayout("calldetail")

        
    'Load data to the CustomListView
        LoadCallDetails2List
    Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    ' Tried this as I remember that I read somewhere in the Forum that I should disable
    ' the click event of the CustomListView
    Sub clvCallDetails_ItemClick(Index As Int, Value As Object)
       
    Return False
    End Sub

    Sub LoadCallDetails2List
        clvCallDetails.Clear

        
    'Creating the Panel and other views to be placed on the Panel. Finally this Panel is added to the CustomListView
        Dim oPanel As Panel
        oPanel.Initialize(
    "")
        oPanel.Color = 
    Colors.White

        
    Dim oLblCustMob As Label
        oLblCustMob.Initialize(
    "")
        oLblCustMob.Text = 
    "Mobile No :"
        oLblCustMob.Gravity = 
    Gravity.RIGHT
        oLblCustMob.TextSize = 
    14
        oLblCustMob.TextColor = 
    Colors.Gray

        
    Dim oLblCustMob_Data As Label
        oLblCustMob_Data.Initialize(
    "")
        oLblCustMob_Data.Text =  
    "12345-67890"
        oLblCustMob_Data.Gravity = 
    Gravity.LEFT
        oLblCustMob_Data.TextSize = 
    14
        oLblCustMob_Data.TextColor = 
    Colors.Gray

        oPanel.AddView(oLblCustMob       ,
    0%x , 75dip , 35%x , 25dip )
        oPanel.AddView(oLblCustMob_Data ,
    37%x , 75dip , 55%x,  25dip )         

        
    ' Adding Panel to the CustomListView
        clvCallDetails.Add(oPanel, 280dip"Test")             

    End Sub

    ' Need to capture the click of this label
    Sub oLblCustMob_Data_Click
        
    Msgbox("Clicked in the Mobile Number","Test")
    End Sub
    Regards

    Anser
     
  2. sorex

    sorex Expert Licensed User

    change

    Code:
    oLblCustMob.Initialize("")
    to

    Code:
    oLblCustMob.Initialize("eventname")
    then you can use something like

    Code:
    sub eventname_click
    log("clicked")
    end sub
     
    Erel, Anser and RandomCoder like this.
  3. Anser

    Anser Active Member Licensed User

    Thanks,

    Your suggestion worked. I was so dump:)

    Regards
    Anser
     
Loading...