I'm trying to smoothly scroll to last element of a list after adding an element to the arrayadapter associated with the listview. The problem is that it just scrolls to a random position
arrayadapter.add(item);
//DOES NOT WORK CORRECTLY:
listview.smoothScrollToPosition(arrayadapter.getCount()-1);
//WORKS JUST FINE:
listview.setSelection(arrayadapter.getCount()-1);
Do you call
arrayadapter.notifyDataSetChanged()
after you calledarrayadapter.add()
? Also to be sure,smoothScrollToPosition
andsetSelection
are methods available inListView
notarrayadapter
as you have mentioned above.In any case see if this helps: smoothScrollToPosition after notifyDataSetChanged not working in android