Android Question XCustomListView Problem

Big Dave

Member
Licensed User
Longtime User
I am trying to follow the XcustomListView video tutorial and create a list containing three fields. No matter what I change or do I cannot get it to work and I am now getting an error "Parameter name cannot hide variable global name" . I would appreciate some pointers as to what I am doing wrong as I have never used this library before.

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

    Private XUI As XUI

    Type ItemValue (lblReceiptID As String)
    
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.
        
    'v0.1  (17/05/2020) - Initial development
    Private strVersion As String = "v0.1"
    Private lblVersion As Label

    Private clvPanel As CustomListView
    
    Private ECReceiptSet As ResultSet
    Private lstReceiptID(1) As List
    Private lstReceiptDate(1) As List
    Private lstReceiptRetailerID(1) As List
    Private lstReceiptAmount(1) As List
    Private lstReceiptChargeStoreID(1) As List
    Private lstReceiptNotes(1) As List
    Private lstReceiptPhoto(1) As List
    Private lstReceiptClaimID(1) As List
    Private lstReceiptClaimPart(1) As List

    Private lblReceiptDate As String
    Private lblRetailer As String
    Private lblReceiptID As String

    Private intRetailerID As Int
    Private strRetailerName As String
    
    Private strStoreID As Int
    Private strStoreName As String
    
    
    Private lblBack As Label
        
    Private strSQLQuery As String
        
End Sub

Sub Activity_Create(FirstTime As Boolean)
    
    SelectReceiptList

    DateTime.DateFormat = "dd/MM/yy"
    
    Activity.LoadLayout("ECS20")
    
    lblVersion.Text = strVersion

    For x = 1 To 5
        Dim iv As ItemValue
        iv.Initialize
        clvPanel.Add(CreateItem(lblReceiptDate, lblRetailer, lblReceiptID), "")
    Next
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub CreateItem(lblReceiptDate As String, lblRetailer As String, lblReceiptID As String) As B4XView
    
    Dim p As B4XView = XUI.CreatePanel("")
    
    p.SetLayoutAnimated(0, 0, 0, 100%x, 120dip)
    p.LoadLayout("ECS20clv")
    
    lblReceiptDate = "22/05/20"
    lblRetailer = "Ebay"
    lblReceiptID = "2005003"
    
    Return p
    
End Sub
 

udg

Expert
Licensed User
Longtime User
Just a guess. One view in the panel layout is named lblReceiptDate. Once renamed the parameter for createitem a .text should be added when assigning value in code.
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
Thanks both for your replies. The code is referred to in ECS20 with the main layout being the same name and the custom view is ECS20clv. udg I understand about label fields having the .Text but I think the problem is something else. I have several label fields in ECS20clv, I am just not sure how to create the view within ECS20 and populate the fields with data from a database.
 

Attachments

  • ExpenseClaimsSystem.zip
    62.1 KB · Views: 231
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Basically you were declaring global variables with the same names as your CLV Labels (incorrect) , then passing them to the CLV (correct) , but also using them in the
CreateItem Sub signiture/parameters ... (incorrect).

also noticed there is a Type declaration using View name as well.

There was an issue/problem? with 2 Labels, which I deleted and recreated. (Properties will have changed !)

Your edited project will explain better... I could not run and test as there were a few missing libs etc and other reasons etc.
 

Attachments

  • ExpenseClaimsSystem 2.zip
    62.6 KB · Views: 240
Last edited:
Upvote 0

Big Dave

Member
Licensed User
Longtime User
MangoJack, thank you for your assistance. I have now managed to populate the clv with data and images from the database. I have to admit I am still not fully conversant with how it all works but it does. I am left with a warning message regarding an unused variable "receiptphoto" which I would like to resolve. If you have the time I would welcome your pointers/knowledge in this respect. I also have a minor concern about the loading time of the photos but will raise this as another question to the forum. Again my grateful thanks for your help.
 

Attachments

  • ExpenseClaimsSystem2.zip
    62.4 KB · Views: 211
Upvote 0

Revisable5987

Member
Licensed User
The 'unused variable' is basically what it says on the tin.
You have declared a variable 'ReceiptPhoto' In Sub CreateItem
B4X:
Sub CreateItem(ReceiptID As String, ReceiptDate As String, RetailerName As String, _

                             ReceiptAmount As String, StoreChargeID As String, ReceiptClaimID As String, _

                             ReceiptNotes As String, ReceiptPhoto As InputStream) As B4XView

assigned a value to it
B4X:
clvPanel.Add(CreateItem(outReceiptID, outReceiptDate, outRetailerName, outReceiptAmount, _
                                                        outStoreChargeID, outReceiptClaimID, outReceiptNotes, _
                                                        outReceiptPhoto), outReceiptID)

But then you haven't done anything with it.
B4X:
Sub CreateItem(ReceiptID As String, ReceiptDate As String, RetailerName As String, ReceiptAmount As String, StoreChargeID As String, ReceiptClaimID As String, ReceiptNotes As String, ReceiptPhoto As InputStream) As B4XView

    Dim p As B4XView = XUI.CreatePanel("")
    
    p.SetLayoutAnimated(0, 0, 0, 100%x, 153dip)
    p.LoadLayout("ECS20clv")
    
    lblReceiptID.Text = ReceiptID
    lblReceiptDate.Text = ReceiptDate
    lblRetailerName.Text = RetailerName
    lblReceiptAmount.Text = ReceiptAmount
    lblStoreChargeID.Text = StoreChargeID
    lblReceiptClaimID.Text = ReceiptClaimID
    lblReceiptNotes.Text = ReceiptNotes
    imgPhoto.SetBackgroundImage(bmp.Rotate(90))
    Return p
    
End Sub
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
The warning stems from the fact .. In the Sub CreateItem signature you have a parameter ReceiptPhoto but it was not used.
Instead you used a global var BMP to fill the ImageView in this sub.

Personally I would try to reduce the use of global variables (only declare variables if they are referenced by multiple subs / routines etc. ) otherwise declare locally.

I have made corrections where necessary and commented some suggested changes.

Cheers
 

Attachments

  • ExpenseClaimsSystem 3.zip
    62.7 KB · Views: 220
Upvote 0
Top