How to scroll to the new added item in a ListView

Posted by Thomas on Stack Overflow See other posts from Stack Overflow or by Thomas
Published on 2010-05-07T15:19:35Z Indexed on 2010/05/07 15:58 UTC
Read the original article Hit count: 392

Hi all

My application show a ListView with a button which allow user to add an element. When the user clicks on this button, another Activity is started to allow user to populate the new element. When the add is finished, we return to the previous Activity with the ListView and I would like to scroll to the new element. Note that this element is not necessarily at the end of the ListView because there is an "order by" when I retrieve the datas from the database.

I know I need the cursor position of the new element to make the ListView scrool to it, but the only info I have about this element is its id, so how to convert this id to cursor position ? Do I have to loop on the cursor to find the position ?

Thanks in advance

© Stack Overflow or respective owner

Related posts about android

Related posts about listview