开发者

TextViews inside a loop

开发者 https://www.devze.com 2023-01-21 12:40 出处:网络
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 d开发者_如何学JAVAynamically corresponding to the size of Array? H

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 d开发者_如何学JAVAynamically 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 : http://developer.android.com/guide/tutorials/views/hello-listview.html

0

精彩评论

暂无评论...
验证码 换一张
取 消