Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ protected void onCreate(Bundle savedInstanceState) {

ArrayList<Integer> numbersArray = new ArrayList<Integer>();
ExpandableHeightListView expandableListView = (ExpandableHeightListView) findViewById(R.id.expandable_listview);


// If you do not want scroll to go to the bottom of page when changed height of the listview.
expandableListView.setFocusable(false);

int i;
for (i=0; i<=20; i++){
numbersArray.add(i);
Expand All @@ -28,8 +31,11 @@ protected void onCreate(Bundle savedInstanceState) {

expandableListView.setAdapter(itemsAdapter);

// No required.
// This actually do the magic
expandableListView.setExpanded(true);
// expandableListView.setExpanded(true);


}

@Override
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ Expand ExpandableHeightListView **programmatically**:
ExpandableHeightListView expandableListView = (ExpandableHeightListView) findViewById(R.id.expandable_listview);

expandableListView.setAdapter(adapterName);

// This actually does the magic
expandableListView.setExpanded(true);
```

It also works well with **GridView**.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
}
// 2017.02.06 :: no need to write setExpanded method anymore
@Override
public void setAdapter(ListAdapter adapter) {
super.setAdapter(adapter);
setExpanded(true);
}
}