Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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). 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?

like image 359
Ben Avatar asked Nov 14 '22 09:11

Ben


1 Answers

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.

like image 50
Yoni Samlan Avatar answered Dec 10 '22 15:12

Yoni Samlan