Search code examples
blackberryscrolllistfield

Blackberry - prevent ListField from scrolling after removing an item


I have a ListField which is a long vertical list of items you can select and delete. Upon deleting an item, the list scrolls back to the top. I can use setSelectedIndex(rowIndex) to return to the spot in the list I had been viewing, but this will not preserve the rows I had been viewing on screen. Instead, the row appears at the bottom of the screen because it stopped scrolling once the correct index appeared on screen.

Is there a way I can remove a row and preserve my view/spot of the list?


Solution

  • Just realized I was using the wrong ListField.setSize() function.

    ListField.setSize(int size) sends your focus back to the top of the list, but you can use ListField.setSize(int size, int focusRow) to leave the focus at "currentIndex" if you want. Hope this helps somebody