Android Question changing corresponding objext in object-array

Discussion in 'Android Questions' started by gruizelgruis, Mar 12, 2015.

  1. gruizelgruis

    gruizelgruis Member Licensed User

    I modified the "AHViewPager" example a bit and added a scrollview.
    In the,
    "Sub CreatePanel(PanelType As Int, Title As String) As Panel" sub, I added the folowing

    within the select case structure

    Code:
    Case TYPE_SCROLLVIEW
                
    Dim SV As ScrollView
                SV.Initialize(
    0)
                
    Dim pnl As Panel
                pnl = SV.Panel
            
            
                
    For i = 0 To 29
                    
    Dim Lbl_Count As Label
                    
    Dim Lbl_Name As Label
                    
    Dim Cmd_Plus As Button
                    
    Dim Cmd_Min As Button

                
                    Cmd_Plus.Initialize(
    "Cmd_plus")
                    Cmd_Min.Initialize(
    "Cmd_Min")
                    Lbl_Count.Initialize(
    "")
                    Lbl_Name.Initialize(
    "")
                
                    Cmd_Plus.Text = 
    "+"
                    Cmd_Min.Text =
    "--"
                
                    Lbl_Name.Text = i & 
    "Omschrijving"
                    Lbl_Name.TextSize = 
    32
                    Lbl_Count.TextSize = 
    32
                    Lbl_Count.Text = 
    "+"
                    pnl.AddView(Lbl_Count, 
    0, height * (i - 1), 50dip, height)
                    pnl.AddView(Lbl_Name, 
    55dip, height * (i - 1), 100%x-75dip, height)
                    pnl.AddView(Cmd_Plus, 
    100%x-80dip, height*(i-1),15%x, height)
                    pnl.AddView(Cmd_Min, 
    100%x-60dip, height*(i-1),15%x, height-10%y)
                    Cmd_Min.Visible = 
    False '// only gets shown when count > 0
                Next
                pnl.height = i * height
                pan.AddView(SV, 
    00, FILL_PARENT, FILL_PARENT)
             ......

    I know how to catch the "Cmd_add_click" event using reflexion

    Code:
    Sub Cmd_Plus_click()
    Dim Btn As Button

    Btn = 
    Sender

    Msgbox (Btn.Text ,"klik")
    ....
    How can I set the correct Lbl_Count.text after the cmd_plus_click event.
    How do I get the correct handle on the correct label. ?

    Please advice
     
    Last edited: Mar 12, 2015
  2. DonManfred

    DonManfred Expert Licensed User

    Use code tags when posting code! It is much easier readable for everyone
     
  3. gruizelgruis

    gruizelgruis Member Licensed User

    Changed to posting donmanfred. thank you for pointing that out
     
    DonManfred likes this.
  4. stevel05

    stevel05 Expert Licensed User

    There are a few ways you could do this, probably the simplest would be to add a reference to the Label in the Buttons Tag:

    Code:
    Cmd_Plus.Tag =  Lbl_Count
    Cmd_Min.Tag = Lbl_Count
    Then

    Code:
    Sub Cmd_Plus_click()
    Dim Btn As Button

    Btn = 
    Sender

    Dim Lbl As Label = Btn.Tag
    Lbl.Text = Lbl.Text + 
    1

    Msgbox (Btn.Text ,"klik")
     
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