Android Question Custom List View how to Extract Edit.text Data?

Condata Informatica

Member
Licensed User
I have this Block of code

B4X:
Sub Find_items_customLSTview
    Dim i As Int 
    Dim iv As ItemValue= CustomListViewPRODUTOSESCALONADOS.GetValue(i)
    Dim qtdeItems As Int 
        For i=0 To  CustomListViewPRODUTOSESCALONADOS.Size -1 
        qtdeItems =    EditTextQTDECustomListView.Text
                 
        If qtdeItems > 0 Then
            Log( CustomListViewPRODUTOSESCALONADOS.GetValue(i))
           
        End If
    Next
   
End Sub

OBS:but the var qtdeItems always get the first value of the Index .
OBS2: I want a way to get only the EDIT QTDE view when it is greater than 0, but I did not find a way to do this. any suggestion ?
 

mangojack

Well-Known Member
Licensed User
Longtime User
Firstly ... this line will always return the value of the first item ... ie: i always = 0
B4X:
Dim i As Int
Dim iv As ItemValue= CustomListViewPRODUTOSESCALONADOS.GetValue(i)


if you were passing an index to the sub (to test a single value) it would make sense .. ie:
B4X:
Sub Find_items_customLSTview(index)
    Dim iv As ItemValue= CustomListViewPRODUTOSESCALONADOS.GetValue(index)

What is ItemValue ?




try this ...
B4X:
For i=0 To CustomListViewPRODUTOSESCALONADOS.Size -1
    Dim pnl As B4XView = CustomListViewPRODUTOSESCALONADOS.GetPanel(i)
    If pnl.GetView(0).Text > 0 Then  'view(0) = 1st edittext on panel.. refer order in Designer ViewTree for Item/Row layout
        Log( "Yes " & CustomListViewPRODUTOSESCALONADOS.GetValue(i))    
    End If
Next



This is just a longer method .. but might make it clearer to you.
B4X:
For i=0 To  CustomListViewPRODUTOSESCALONADOS.Size -1
    Dim pnl As B4XView = CustomListViewPRODUTOSESCALONADOS.GetPanel(i)
    Dim edtText As B4XView = pnl.GetView(0)
    If edtText.Text > 0 Then
    'ditto


ps: just a suggestion .. possibly rename your CLV to clvPRODUTOSESCALONADOS
 
Last edited:
Upvote 0

Condata Informatica

Member
Licensed User
Firstly ... this line will always return the value of the first item ... ie: i always = 0
B4X:
Dim i As Int
Dim iv As ItemValue= CustomListViewPRODUTOSESCALONADOS.GetValue(i)


if you were passing an index to the sub (to test a single value) it would make sense .. ie:
B4X:
Sub Find_items_customLSTview(index)
    Dim iv As ItemValue= CustomListViewPRODUTOSESCALONADOS.GetValue(index)

What is ItemValue ?




try this ...
B4X:
For i=0 To CustomListViewPRODUTOSESCALONADOS.Size -1
    Dim pnl As B4XView = CustomListViewPRODUTOSESCALONADOS.GetPanel(i)
    If pnl.GetView(0).Text > 0 Then  'view(0) = 1st edittext on panel.. refer order in Designer ViewTree for Item/Row layout
        Log( "Yes " & CustomListViewPRODUTOSESCALONADOS.GetValue(i))    
    End If
Next



This is just a longer method .. but might make it clearer to you.
B4X:
For i=0 To  CustomListViewPRODUTOSESCALONADOS.Size -1
    Dim pnl As B4XView = CustomListViewPRODUTOSESCALONADOS.GetPanel(i)
    Dim edtText As B4XView = pnl.GetView(0)
    If edtText.Text > 0 Then
    'ditto


ps: just a suggestion .. possibly rename your CLV to clvPRODUTOSESCALONADOS[/code]


Thank u for this, help me much


i got a error message whit that code , but i got this because, in the designer i got a Panel,
wich contains anothers views,
so to solve that
i got

B4X:
For i=0 To CustomListViewPRODUTOSESCALONADOS.Size -1
        Dim pnl As B4XView = CustomListViewPRODUTOSESCALONADOS.GetPanel(i)
        Dim edtText As B4XView = pnl.GetView(0).GetView(2)
        If edtText.Text > 0 Then
            Log( "Yes " & CustomListViewPRODUTOSESCALONADOS.GetValue(i))
        End If
    Next
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Without knowing your exact Item / Row layout , I cant comment if this secondary panel is really needed .. so I will leave it here.

Glad you got it working.
 
Upvote 0
Top