Android Question text button property ad array declaration

Discussion in 'Android Questions' started by Oldmanenzo, Mar 29, 2015.

  1. Oldmanenzo

    Oldmanenzo Member Licensed User

    is possible to declare the text property of a button as an array???

    i have this error
    B4A version 4.30
    Parsing code. 0.04
    Compiling code. Error
    Error compiling program.
    Error description: Missing parameter.
    Occurred on line: 59
    Mese().Text =Array As String("Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic")
    Word: (

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

        
    Private Mese(12As Button
        
    Private img(2As Bitmap
        
    Private Pnl As Panel
    End Sub
    assignment this

    Code:
    Sub InitializeButton
        
    Dim timg As Int
        
    Dim index As Int = 5
        
    For n=0 To 11
            Mese(n).Initialize (
    "Mese")
            
    If n=0 Then
                Mese(n).SetBackgroundImage(img(
    0))
            
    Else
                Mese(n).SetBackgroundImage (img(
    1))
            
    End If
            Mese(n).Gravity =
    Bit.OR(Gravity.CENTER_HORIZONTAL, Gravity.CENTER_VERTICAL)
            Mese(n).Typeface =
    Typeface.DEFAULT_BOLD
            Mese(n).TextSize =
    20
            Mese(n).TextColor =
    Colors.White
            Mese(n).Tag =n
            Pnl.AddView (Mese(n),index, 
    5dip100dip40dip)
            index=index +
    105dip
        
    Next
        Mese().Text =
    Array As String("Gen""Feb""Mar""Apr""Mag""Giu""Lug""Ago""Set""Ott""Nov""Dic")
    but this assignmente work fine

    Code:
    '    Mese(0).Text="Gen."
    '    Mese(1).Text ="Feb."
    '    Mese(2).Text ="Mar."
    '    Mese(3).Text="Apr."
    '    Mese(4).Text ="Mag."
    '    Mese(5).Text ="Giu."
    '    Mese(6).Text="Lug."
    '    Mese(7).Text ="Ago."
    '    Mese(8).Text ="Set."
    '    Mese(9).Text="Ott."
    '    Mese(10).Text ="Nov."
    '    Mese(11).Text ="Dic."
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    No. You can however assign it like this:
    Code:
    Dim items() As String = Array As String(...)
    For n = 0 to 11
    ...
    Mese(n).Text = Items(n)
    Next
    There is no special relation between the labels.
     
  3. Oldmanenzo

    Oldmanenzo Member Licensed User

    thanks Erel
     
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