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

Android Question timer problem

Discussion in 'Android Questions' started by John Decowski, Jul 21, 2019.

  1. John Decowski

    John Decowski Member Licensed User

    Im getting this error upon activating my timer no idea why. Ive used timers in the past and havent go this code before?
    Code:
    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.
        Dim slidedown As Timer
        slidedown.Initialize(
    "SlideDown1" ,1000)
        slidedown.Enabled = 
    False
        
    Dim Slidertop As Long
    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 pnlSlide As Panel
        
    Private imgTradeBuddyLogo2 As ImageView
        
    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("tbmain")
        pnlSlide.Top = ((pnlSlide.Height * -
    1) + (imgTradeBuddyLogo2.Height) ) + 5dip
        Slidertop = pnlSlide.top
        imgTradeBuddyLogo2.top = pnlSlide.height - imgTradeBuddyLogo2.height
    ' this adds it up and multiplys by neg 1 to turn number negative
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Sub SlideDown1_tick
        
    If pnlSlide.Top > = 1 Then
            slidedown.Enabled = 
    False
        
    Else
            pnlSlide.Top = pnlSlide.Top + 
    10
        
    End If
    End Sub

    Sub imgTradeBuddylogo1_Click
        
    'slidedown.Enabled = True
    End Sub

    Sub imgTradeBuddyLogo2_Click
        slidedown.Interval = 
    10
        slidedown.Enabled = 
    True
    End Sub
    Error code:



    thanks in advance
     
  2. MarkusR

    MarkusR Well-Known Member Licensed User

    u need to move this into activity create.
    (b4a 9.3 wrote a info at mouse over.)
    Code:
    slidedown.Initialize("SlideDown1" ,1000)
    slidedown.Enabled = 
    False
    u can also use breakpoints or log(..)
     
  3. John Decowski

    John Decowski Member Licensed User

    thanks @MarkusR will try! I grabbed the code from a b4j app I made and maybe its fine in b4j?
     
    MarkusR likes this.
  4. Erel

    Erel Administrator Staff Member Licensed User

    You should never write code in Process_Globals. Don't ignore the warnings...
     
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