Using loop to initialize/draw textView items

Put your problem here if it does not fit any of the other categories.

Using loop to initialize/draw textView items

Postby Tollas » Fri Jun 11, 2010 4:38 pm

I have 12 TextView fields named textView1 - textView12.
Each TextView will have 2 attributes set: SetText &
SetBackgroundColor which are read from an array (textValue[] and textBackground[]).

What I would like to do is write a for (or similar loop) statement to draw them in a loop rather than write each one individually.

Something like
Code: Select all
for(int Z=1; Z<=12; Z++){
     TextView textViewz = (TextView)findViewById(;

Unfortunately is looks for the variable textViewZ instead of textView1.
Posts: 3
Joined: Fri May 28, 2010 5:15 pm


Re: Using loop to initialize/draw textView items

Postby luugiathuy » Fri Jun 11, 2010 5:10 pm


I think first you should create an array int textViewID[12] and store the value of (Z = 1..12).

Then use it for your loop.

Hope this helps!
Junior Developer
Junior Developer
Posts: 10
Joined: Tue Jun 01, 2010 3:16 am


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 3 guests