Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 23
Registered: ‎12-21-2009
My Device: 8800
My Carrier: Zain
Accepted Solution

How to scroll the ListField to the selected index

Hi,

 

I have a simple question but unfortunately I couldn't do it until now. I change the selected index of the ListField before show it by using ListField.setSelectedIndex( index ); the index refer to invisible row, my problem is the list doesn't scroll to show this invisible row it keeps drawing the list from row 0 as normal.

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How to scroll the ListField to the selected index

Are you setting it to negative value?


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 23
Registered: ‎12-21-2009
My Device: 8800
My Carrier: Zain

Re: How to scroll the ListField to the selected index

no, I am using a valid positive numbers.

 

Let ma clarify my problem a little bit, when I jump to the ListField the focus cursor jump direct to the selected row which is as expected. But I need the list to start drawing from the selected row even when I am on another Field.

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How to scroll the ListField to the selected index

Only one filed will be having the focus at a time.


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 23
Registered: ‎12-21-2009
My Device: 8800
My Carrier: Zain

Re: How to scroll the ListField to the selected index

I know,

 

I just want the list start drawing it's rows from the selected index rather than from row zero even when it doesn't has the focus.

 

Thanks for your help,

Mahdi

Developer
Posts: 23
Registered: ‎12-21-2009
My Device: 8800
My Carrier: Zain

Re: How to scroll the ListField to the selected index

Snapshot

 

This is a snapshot of my application, when the user start typing the word in the search field I go through the list item and find the index of the matching word then I need the ListField to start drawing it's items from this index (Filtering the list) without deleting or adding any item to the list.

Developer
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE
My Carrier: Vodafone NL

Re: How to scroll the ListField to the selected index

Do setSelectedIndex() and invalidate() methods of ListField help?

Developer
Posts: 23
Registered: ‎12-21-2009
My Device: 8800
My Carrier: Zain

Re: How to scroll the ListField to the selected index

 


Eugen wrote:

Do setSelectedIndex() and invalidate() methods of ListField help?


 

I've already use them and no success

 

Developer
Posts: 168
Registered: ‎11-22-2009
My Device: 9000 Bold, 8300 Curve

Re: How to scroll the ListField to the selected index

[ Edited ]

I'm assuming you have a list model overriding the drawListRow method. If that's the case, I imagine you could put code in there to exclude drawing the rows that you don't want to see. Then just do an invalidate() and that should work.

 

Something like this...

 

 public void drawListRow(ListField list, Graphics g, int index, int y, int w) {

if (index < newStartingIndex) {return;}  //don't draw row

 

...

..

 

 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How to scroll the ListField to the selected index

check for indexOfList method too..


Use Search. "Accept Solution" If the problem is resolved.