Android Question using a variable to access a view

Discussion in 'Android Questions' started by clydebamford, Jul 1, 2015.

  1. clydebamford

    clydebamford Member Licensed User

    I have many checkbox views in designer that I would like to access with code and it would be trivial if I could use a variable in a for loop to change their text color or similar property
    ie cb1, cb2, cb3 could be accessed easily in a for loop rather than repeating the code addnausium for each checkbox, does that make sense?
     
  2. DonManfred

    DonManfred Expert Licensed User

    put the objects into a list after you loaded the layout.
    This has discussed a lot of times in forum. Try the forumsearch
     
  3. Cableguy

    Cableguy Expert Licensed User

    Add the views to a list if you are adding them in the designer or if you are adding them in code, just array them

    Code:
    dim checkbox(10as checkbox

    For n = 0 to checkbox ().lenght -1
    Checkbox(n).checked = False
    Next
     
  4. clydebamford

    clydebamford Member Licensed User

    Thanks guys, I had looked at some other posts but just couldn't get my head around it, anyway I finally made it work!
     
    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