Android Question FindViewByTag Problem

Discussion in 'Android Questions' started by ykucuk, Apr 9, 2015.

  1. ykucuk

    ykucuk Active 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: Apr 9, 2015
  2. RandomCoder

    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?
    Code:
    If Name = v.Tag AND v is EditText Then Return v
     
    DonManfred likes this.
  3. ykucuk

    ykucuk Active Member Licensed User

    it works. thank you
     
    RandomCoder likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice