KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to display a dynamically-growing list of strings with a checkbox in a GridView, which is itself in a TableLayout. I can display these "checkboxed" strings fine in a row. My problem occurs when I let the user dynamically add new strings in the GridView. I created a custom adapter that receives the list of strings. Say we have n strings. The adapter returns 'n + 1' for the items count; in getView, it returns: a View with a LinearLayout, itself having a CheckBox and an EditText for the first n items, a LinearLayout with a simple button, with a '+' caption for the 'n + 1'th item. So far so good. When the '+' button is clicked, I add an empty string to the list of strings and call notifyDataSetChanged in the adapter. The GridView redraws itself with one more item. BUT it keeps its original height and creates a vertical scrollbar. I'd like the GridView to expand its height (i.e. take up more space on screen and show all items). I've tried to change the screen to a vertical LinearLayout instead of a TableLayout, but the results is the same. Here is the layout of my screen: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <!-- other lines omitted --> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/wine_rack_explanation" android:layout_gravity="center_vertical" /> <GridView android:layout_width="fill_parent" a
Tags (comma-separated)
Save Edits
Cancel