10
TextView textView1= (TextView) dialog.findViewById(R.id.textView1);

I d like to create something like this:

for (int i=0; i<100; i++) {
   TextView textView= (TextView) dialog.findViewById(R.id.textView+i);
}

how can i do that?

Leslie

lacas
  • 13,928
  • 30
  • 109
  • 183

1 Answers1

25

See getIdentifier. Basically, you want something like:

for (int i=0; i<100; i++) {
   int resId = getResources().getIdentifier("textView" + i, "id", getPackageName());
   TextView textView = (TextView) dialog.findViewById(resId);
}
Felix
  • 88,392
  • 43
  • 149
  • 167