Reputation: 286
In the OnGroupClickListener
of an ExpandableListView
, I have:
expLista.setOnGroupClickListener(new OnGroupClickListener()
{
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id)
{
// Pongo el valor de grupo clickeado correctamente
grupoCLickeado = groupPosition;
expLista.smoothScrollToPosition(groupPosition);
}
}
This works fine except when clicking the last group. Once I click the last group, it scrolls until the group view, but not to down all.
Is it possible to scroll down more, to the end of the expandable list view?
Upvotes: 1
Views: 4159
Reputation: 3562
Try this
private void scrollToEnd() {
expLista.post(new Runnable() {
@Override
public void run() {
// Select the last row so it will scroll into view...
expLista.smoothScrollToPosition(getCount() - 1);
}
});
}
private int getCount() {
int count = 0;
for (int i = 0; i < adapter.getGroupCount(); i++) {
for (int j = 0; j < adapter.getChildrenCount(i); j++) {
count++;
}
count++;
}
return count;
}
Upvotes: 1
Reputation: 12664
In General you don't need to scroll for first group in ExpadableListView. set transcriptMode other than first group in ExpadableListView.
getExpandableListView().setOnGroupExpandListener(new OnGroupExpandListener() {
@Override
public void onGroupExpand(int position) {
if(position == 0) {
getExpandableListView().setTranscriptMode(ExpandableListView.TRANSCRIPT_MODE_DISABLED);
}else{
getExpandableListView().setTranscriptMode(ExpandableListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
}
}
});
Upvotes: 2
Reputation: 514
Try to write the following for this component android:transcriptMode="alwaysScroll"
Upvotes: 2