En mi aplicación tenía una necesidad similar. Usé getListView().setSelection()
para definir la posición de la lista, funciona bien sin desplazamiento.
Si se tiene en cuenta que tiene 2 actividades, ActivityA que muestra la lista de un cursor y ActivityB que tiene un formulario para agregar un nuevo elemento. En fin, ActivityB debe devolver el cursor de Identificación del artículo, después ActivityB
puede recuperar la posición del elemento con el id, y establecer la posición, al igual que este código:
/* check intent Id to scroll to the right item after update or delete */
if (getIntent().hasExtra(ITEMID_INTENT_KEY))
{
long id = getIntent().getLongExtra(ITEMID_INTENT_KEY, 0);
int position = getPositionFromId(id);
getListView().setSelection(position > 0 ? position - 1 : 0);
getIntent().removeExtra(ITEMID_INTENT_KEY);
}
(...)
private int getPositionFromId(long id)
{
mCursor.moveToFirst();
do
{
Long cursorId = mCursor.getLong(mCursor.getColumnIndexOrThrow(yourIdColumn));
if (cursorId.longValue() == id)
{
return mCursor.getPosition();
}
}
while (mCursor.moveToNext());
return 0;
}