I am trying to dynamically add textviews to a linearLayout, say the textview is boo and the linearlayout is foo.
TextView boo = new TextView(this)
LinearLayout foo = findViewByID(R.id.examplelayout)
I am trying to add the textview right below the existing textview in the layout. when I add it
foo.addView(boo, int position new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
how do I specify the position parameter to achieve it, because the default one is to add it above. I have been searching the docs but couldn’t find any explanation for the position parameter. all I got is this:
public void addView (View child, int index, ViewGroup.LayoutParams params)
Since: API Level 1
Adds a child view with the specified layout parameters.
Parameters
child the child view to add
index the position at which to add the child
params the layout parameters to set on the child
any headsup would be appreciated.
You can use method foo.getChildCount()