Scroll ListView to position.
I needed to scroll the list ( ExpandableListView to be exact ) to position.I found this thread where Romain Guy said it got fixed in Froyo. And it is. There is a smoothscrollToPosition in SDK8 and up. As i needed to go lower than 8 here is mine workaround. If anybody knows better way let me know
class ScrollList extends Thread {
final int position = mListView.getFlatListPosition(ExpandableListView
.getPackedPositionForGroup(mListAdapter.getTestGroupPosition()));
View itemView = mListView.getChildAt(position);
int yPos = itemView.getTop();
public void run() {
while (yPos >= 20) {
try {
yPos -= 5;
sleep(20);
mListView.post(new Runnable() {
public void run() {
mListView.setSelectionFromTop(position, yPos);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};