Android Question How to get the text of an editext in a panel in scrollview

DALB

Active Member
Licensed User
Hello everyone.

I have a layout named PNLS
In PNLS I have 2 labels and 1 EditText TXTS
With a loop, I add some panels PNLS in a scrollview named SCV
I invite the user to entrer datas in the editTexts named TXTS

Question:
How can I get the texts of each editText (to next insert in a SQLite table) ?

B4X:
For Each w As View In pnls.GetAllViewsRecursive
            Log("pnls " & i & " - " & w.tag)
        Next

With 'w.Tag', I obtain the Tag.
But there is no 'w.Text' (for my EditTexts TXTS) which is possible.

So, How can I get the values entered by the user in the TXTS fields ?

I always have to learn...
Thank you
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Hi @DALB ,
Why are you using a scrollView, A customListView would be much better for this.
https://www.b4x.com/android/forum/t...-cross-platform-customlistview.84501/#content

you can then get the edittext with something like this:
B4X:
for i = 0 to clv.size-1
       private pnl as panel = clv.getpanel(i)
       For Each w As View In pnl.GetAllViewsRecursive
           if (v is EditText) then
                private et as edittext = v
                log($"edit text contains ${et.text}"$)
           end if
        Next
next
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
In fact, I would probably save the edittext in the tag of the panel to save all the messing around with getAllViewsRecursive.

See https://www.b4x.com/android/forum/t...-views-in-xcustomlistview.112067/#post-698874

B4X:
for i = 0 to clv.size-1
       private pnl as panel = clv.getpanel(i)
       private v as object = pnl.tag
           if (v is EditText) then
                private et as edittext = v
                log($"edit text contains ${et.text}"$)
           end if
next
 
Upvote 0

DALB

Active Member
Licensed User
Hello Andrew.

Why not ? I didn't think about using CustomListView. So, yes, I'll try this. It seems easyer to use.
Thanks much for this
 
Upvote 0

DALB

Active Member
Licensed User
it works fine ! one thousand of thanks !
 
Upvote 0
Top