I have a list view of 300 mp3 songs and suppose song 52 is playing. So I want next time when user opens the list of song, the list row in front of him must starts from row 52 (while up and down are still rows). I tried using
public View getViewByPosition(int pos, ListView listView) {
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
if (pos < firstListItemPosition || pos > lastListItemPosition ) {
return listView.getAdapter().getView(pos, null, listView);
} else {
final int childIndex = pos - firstListItemPosition;
return listView.getChildAt(childIndex);
}
}
and also
adapter.getItem(52);
But both are pointless methods and dont take me to row 52. (These methods are what I used, but might not be the solution) Also I got no solution googling it. Please let me know if you guys can deal with this !!
A big thanks to you for listening!