android – TextViews inside a loop – Education Career Blog

I want to display String Array values inside a for loop. I need to display the each value to each TextView. How can I create TextView dynamically corresponding to the size of Array? How can I specify ID for each one ? Please give me the solution… Thank You..


As written in the comments, you should use a ListView : It’s dedicated to such a purpose.

It’s definitely a bad idea because instantiating TextViews in a loop is not an optimized behavior. If you have many items in your array, it will take a lot of CPU resources and it will fill up the memory.

Take a look to the ListView object : it’s easier to implement and optimized for the system.
Check this for more info :

Leave a Comment