Android Question FindViewByTag Problem

ykucuk

Well-Known Member
Licensed User
Hello,

FindViewByTag function is work perfectly but i need get view type also.

I have scrollview with different view types (spinner, edittext , button) and they are all created by user dynamic at runtime

Problem is :
[CODE ]
for

edt= FindViewByTag(scvform, "A" & i)

next
[/CODE ]
it doesn't work because edt can be ( spinner , button or edit ) with number i in loop

Need help


[CODE ]
Sub FindViewByTag(Parent As Panel, Name As String) As View

For Each v As View In Parent.GetAllViewsRecursive

If Name = v.Tag Then Return v

Next

Log("View not found: " & Name)

ReturnNull


End Sub
[/CODE ]
 
Last edited:

RandomCoder

Well-Known Member
Licensed User
Please don't forget to use code tags [CODE ]Your code here..[/CODE ]

If I have understood correctly, you have a ScrollView and on it you have dynamically created other Views each having a unique tag. You only want your function to return the View if the tag matches a View that is an EditText?
B4X:
If Name = v.Tag AND v is EditText Then Return v
 
Top