BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   How to make scroll in the long list ObjectChoiceField (http://www.blackberryforums.com/developer-forum/143833-how-make-scroll-long-list-objectchoicefield.html)

son_tiny 08-05-2008 10:24 PM

How to make scroll in the long list ObjectChoiceField
 
Hi everyone, Could anyone help me out?
My problem is I have a list of ObjectChoiceField having 10 items. It occupies my whole BlackBerry screen. Now I would like to shorten the list having for example 4 items and using scroll to move down to 10th item. Thanks in advance.

simon.hain 08-06-2008 02:21 AM

first you should limit your field to four items. then you overwrite the scrolling behaviour and exchange the items. or you build yourself something to turn the pages like 1-2 small buttons, would make it easier.

son_tiny 08-06-2008 02:37 AM

Thanks, I will try to do what u suggested me.

arifzaman 08-18-2008 04:10 AM

Try with HorizontalFieldManager.

Cheers,
ARIF

son_tiny 08-19-2008 02:45 AM

I tried to use HorizontalFieldManager but I cant solve the problem. Here is my code. Can u and simon.hain help me out?

public class LimittedObjectChoiceField extends MainScreen{
public LimittedObjectChoiceField(){
String option[] = {"Opt 1", "Opt 2", "Opt 3", "Opt 4", "Opt 5", "Opt 6", "Opt 7", "Opt 8", "Opt 9", "Opt 10"};
ObjectChoiceField choice = new ObjectChoiceField("Object Choice Field: ", option, 0);
HorizontalFieldManager mgr = new MyHorizontalFieldManager();

mgr.add(choice);

add(mgr);
}
}

class MyHorizontalFieldManager extends HorizontalFieldManager{

public MyHorizontalFieldManager()
{
super();
}
protected void sublayout(int maxWidth, int maxHeight)
{
super.sublayout(width, maxHeight);
setExtent(width, getExtent().height);
}

public int getPreferredWidth()
{
return width;
}

}

CELITE 08-19-2008 10:37 AM

You should be aware that the ObjectChoiceField component uses an internal class to render the choice popup. The object is private so you cannot manipulate it. If you want to achieve what you are trying to do, you will have to write your own popup class. A good way to start is to inherit from screen and override sublayout. Then you can manipulate the position and size of your popup screen with setPosition and setExtent respectively. You can use a VerticalFieldManager as your delegate to the screen to achieve the scrolling effect you're after. Good luck!

son_tiny 08-19-2008 09:39 PM

Thanks for yr kindness. I will do what you mentioned


All times are GMT -5. The time now is 06:14 PM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.