Right... you can't do that. How is it supposed to know that the Z in textViewZ is supposed to be a variable? You would run into all sorts of problems with compiling if it did stuff like this.
You could, however, stick each textView in either an array or an ArrayList and then loop over the indexes of the array, similar to how you are calling textValue and textBackground... So you would have something like this in your for loop: TextView curTextView = myTextViewArray[Z]; curTextView.setText(textValue[Z]); curTextView.setBackgroundColor(textBackground[Z]); Hope that helps, Justin ---------------------------------------------------------------------- There are only 10 types of people in the world... Those who know binary and those who don't. ---------------------------------------------------------------------- On Fri, Jun 11, 2010 at 9:08 AM, Tollas <tolla...@gmail.com> wrote: > I have 12 TextView fields named textView1 - textView12. > Each TextView will have 2 attributes set: SetText & > SetBackgroundDrawable 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 > for(int Z=1; Z<=12; Z++){ > textViewZ.setText(textValue[Z]); > textViewZ.setBackgroundColor(textBackground[Z]); > } > > Unfortunately is looks for the variable textViewZ instead of textView1. > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en