开发者

Android ListViewItem variable content

开发者 https://www.devze.com 2023-02-24 01:55 出处:网络
I have a ListViewItem in which i want to display an array of strings. problem is the array is of variable size. so setting up an xml with a TextView for every item in the array wont work.

I have a ListViewItem in which i want to display an array of strings. problem is the array is of variable size. so setting up an xml with a TextView for every item in the array wont work.

Is there any other way to accomplish this? For example 开发者_运维技巧by defining the layout in code or setting up one TextView and setting up a single string with line breaks?

Any suggestions?


You should use a listadapter and create a class that extends ArrayAdapter and then in your getView function you should implement each row from an arraylist or array. It is not so much easy, you can see a working example here

http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/

0

精彩评论

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