android repeater-like functionality
is there any type of 'repeater' type functionality in android? I have a relative layout (inside a row in a listview) and inside that I'd like to have a series of TextViews be displayed one after the other (as if they are child rows in the listview row). 开发者_JS百科 The issue is that the number of those "child rows" will vary. is there any way to do this, or should i just create the TextView objects in code, and programatically add them to a linear or table layout?
The closest thing (besides ListView/ListAdapter, naturally) that I can think of offhand is ViewSwitcher and ViewSwitcher.ViewFactory, but there's really nothing magical there: it's an interface that you can call to get a view.
Since it's only one line to get a view and add it to your current hierarchy anyways, though (View.inflate(context, R.layout.somelayout, myContainerViewGroup)
) it feels silly to go with something heavier, but if you feel better wrapping that up in a Factory of some sort, check the AOSP source for ViewSwitcher.
One option is TextViews support Multi-line text. So you could create the text with a StringBuilder using "\n" for new lines, and not have to worry about multiple text views.
精彩评论