Android Question Returning a list of views problem

Discussion in 'Android Questions' started by AbbasMohammed, Jun 24, 2015.

Similar threads

B4A Tutorial Android In-App Billing v3 Tutorial
B4A Library In-App Billing v3 library
B4A Library DJI Drones
B4A Question CallSub2 Error
B4A Tutorial B4x / PHP compatibility thread
  1. AbbasMohammed

    AbbasMohammed Member Licensed User

    Dears,
    Kindly, i need to return a list that contains 2 views to disply it on ScrlPagethat belongs to a parent Class method which is PageShow as below:
    Code:
    Public Sub PageShow
    '    Msgbox("Iam Page :" & PageId &" With MainProducts : " & MainProductList,PageName)
        PageHide
        AddViews
        
    Dim Ivlist As List
        
    Dim MpIv As ImageView:Dim Mpl As Label
        Main.BackConstant =-
    1000
        PageTitle.Text =PageName
        ScrlPage.Panel.Height =ScrlHight
        ScrlPage.ScrollPosition=
    0
         
    For i=0 To MainProductList.Size-1
        Ivlist=MainProduct(i).GetMainProd
        MpIv=Ivlist(
    0):Mpl=Ivlist(1)
        ScrlPage.Panel.AddView (MpIv,MpIv.Left ,MpIv.Top ,MpIv.Width ,MpIv.Height )
        ScrlPage.Panel.AddView (Mpl,Mpl.Left ,Mpl.Top ,Mpl.Width ,Mpl.Height )
        
    Next
    End Sub
    by using GetMainProd method which belongs to child class as below:
    Code:
    Public Sub GetMainProd ()
        
    Dim AV1 As ImageView:Dim AV2 As Label
        
    Dim ViewList As List
        
    If ProductPostion >= 0 Then
        ProdImagView.Initialize (
    "IV")
        ProductLable.Initialize (
    "IV")
        ProdImagView.Bitmap=
    LoadBitmap(File.DirAssets ,"1.jpg")
        ProdImagView.Gravity =
    Gravity.fill
        ProdImagView.Tag =ProductId
        ProductLable.Tag =ProductId+
    1000
        ProductLable.Text=ProductName
        ProductLable.Gravity =
    Gravity.CENTER
        ProductLable.TextSize=
    2%x
        ProductLable.TextColor=
    Colors.Red
        
    If Fav=1 Then
        ProductLable.color=
    Colors.RGB(255,255,175)
        
    Else
        ProductLable.color=
    Colors.Transparent
        
    End If
        AV1=ProdImagView:AV2=ProductLable
        AV1.Left =ProductColumn:AV1.Top =ProdRow:AV1.Width =
    33%x:AV1.Height=33%x
        AV2.Left=ProductColumn:    AV2.Top=ProdRow+
    33%x:    AV2.Width =33%x:    AV2.Height=22%x
        
    End If
        ViewList.Add(AV1):ViewList.Add(AV2)
        
    Return ViewList
    End Sub
    but i get the following error

    Parsing code. 0.02
    Compiling code. 0.02
    Compiling layouts code. 0.00
    Generating R file. 0.01
    Compiling generated Java code. Error
    B4A line: 78
    Ivlist=MainProduct(i).GetMainProd
    javac 1.7.0_71
    src\abbscroll\abbscroll\page.java:312: error: inconvertible types
    _ivlist = (anywheresoftware.b4a.objects.collections.List[])(_mainproduct[_i]._getmainprod());
    ^
    required: List[]
    found: String
    1 error
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Is there any compilation warning in the warnings list?
     
    AbbasMohammed likes this.
  3. AbbasMohammed

    AbbasMohammed Member Licensed User

    its very strange but the error is changed to
    Parsing code. Error
    Error parsing program.
    Error description: Use of undeclared array: ivlist
    Occurred on line: 78
    MpIv=Ivlist(0):Mpl=Ivlist(1)
     
  4. AbbasMohammed

    AbbasMohammed Member Licensed User

    also i tried to add the below , but nothing happend!!!

    Ivlist.Initialize
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You need to declare the return type:
    Code:
    Public Sub GetMainProd As List
     
    AbbasMohammed likes this.
  6. AbbasMohammed

    AbbasMohammed Member Licensed User

    i did it but i still get the following:

    Parsing code. Error
    Error parsing program.
    Error description: Use of undeclared array: ivlist
    Occurred on line: 78
    MpIv=Ivlist(0):Mpl=Ivlist(1)
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    ivlist is a List not an array.
     
    AbbasMohammed likes this.
  8. AbbasMohammed

    AbbasMohammed Member Licensed User

    i shall try MpIv=Ivlist.get(0):Mpl=Ivlist.get(1)
    and tell you the result asap
    thanks
     
  9. AbbasMohammed

    AbbasMohammed Member Licensed User

    Many thanks Erl, it worked:)
     
Loading...