I have a custom listview which changes size when one of the rows is clicked, new rows are added. When the activity first loads there is only one row and two buttons(previous & next) in a tablelayout.
Currently if i have my listview in added to a tablerow & row 2 contains the buttons. The layout height & width are set to wrap_content.
When new rows are added to the listview, the row size does not change and secondly expands to occupy the space that was for buttons. And therefore as a result my buttons disappear.
main.xml
<LinearLayout android:orientation="vertical" style="?fill_parent"
android:layout_weight="1">
<TableLayout style="?fill_parent" android:layout_weight="1" >
<TableRow android:id="@+id/tr1">
<CustomList android:id="@+id/mainview" ndroid:layout_height="wrap_content"
android:layout_width="wrap_content" />
</TableRow>
<TableRow android:layout_height="wrap_content" android:layout_width="match_parent">
<Button android:layout_width="wrap_content" android:id="@+id/button1"
android:text="@string/buttonPrevious" android:layout_height="wrap_content"> </Button>
<Button android:layout_width="wrap_content" android:id="@+id/button2"
android:text="@string/buttonNext" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
How do I dynamically update the row size when the new rows are being added to the views.?
Thanks
Replace TableLayout with a RelativeLayout:
This layout will put your buttons at the bottom of the screen, while the
ListViewwill cover the whole screen.