Suppose within a scroll view I want to have n rows, where n is a number determined by how many items were selected using check boxes on a different screen. I restricted the maximum height the scroll view can take up on the screen by putting it inside a linear layout. Normally you could just add elements by doing something like the following:
<LinearLayout>
<Scroll View>
<TextView>
<TextView>
...
</ScrollView>
</LinearLayout>
but since the number of TextView objects is dependent on how many check boxes were selected on the previous screen, how could I make sure that I add the appropriate number of textView objects within the scrollView?
Best way is to use
RecyclerView
. If you still want to useScrollView
then create a layout for each row or each item. Add that layout toScrollView
from your Java class programmatically number of times you want.