Android Question [ SOLVED] Iterate Views and Get Name and Value

konradwalsh

Active Member
Licensed User
Longtime User
I have been reading over how to Iterate views
As a test, I am using this

B4X:
For i = 0 To panTreasures.NumberOfViews - 1
   If panTreasures.GetView(i) Is FloatLabeledEditText Then
      Log(panTreasures.GetView(i))
   End If
Next

I thought I would be able to extract the i. NAME and the i.Value somehow, but cant figure out how

I appreciate any assistance
 

eurojam

Well-Known Member
Licensed User
Longtime User
you can to do it like this....
B4X:
For Each v As View In panTreasures.GetAllViewsRecursive
      If v.Tag = "yep" Then
         'do something....   
      End If
Next

Views don't have a name, but you can use the tag
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
something like this:
B4X:
  For Each v As View In panTreasures.GetAllViewsRecursive
  If v Is EditText Then
        Dim e As EditText
      e = v
      Log(e.Text)
    End If   
Next
 
Upvote 0

konradwalsh

Active Member
Licensed User
Longtime User
Smallish issue but this may need to be a separate thread

Is it possible to get a FloatEditText tag?
I get a null on FloatEdits but correct response on EditText
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
Sorry, but it MUST be possible to get the name without using the tag.

There is a DialogLibrary XtraViews where I can get views from a layout by using their names, e.g:

B4X:
Dim Dialog As DialogView
Dialog.LoadLayout("DialogInput")

Dim edtSongLocal as EditText = Dialog.Views.EditText("edtSong")

Here the EditText "edtSong" in the layout "DialogInput" is assigned to the local EditText "edtSongLocal" by NAME.
 
Upvote 0

konradwalsh

Active Member
Licensed User
Longtime User
Sorry, but it MUST be possible to get the name without using the tag.

There is a DialogLibrary XtraViews where I can get views from a layout by using their names, e.g:

B4X:
Dim Dialog As DialogView
Dialog.LoadLayout("DialogInput")

Dim edtSongLocal as EditText = Dialog.Views.EditText("edtSong")

Here the EditText "edtSong" in the layout "DialogInput" is assigned to the local EditText "edtSongLocal" by NAME.
hmm
yes but thats assuming I already know the names. Whereas, I wish to iterate over each view and based on the view type, extract its name and value
 
Upvote 0
Top