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
naveensh
Posts: 51
Registered: ‎09-18-2008
My Device: Not Specified

List of CheckBox ( within fixed area ) should scroll vertically

Hello All, 

 

I have a list of checkBox. I have to show that list in fixed area such that

 

if the size of checkBox list increases then the scrollbar should be displayed.

 

(i.e. At first if there are only 3 elements then it will not show scrollbar but if there are more than  elements then it will show first 3 elements then rest elements can be viewed by scrolling the scrollbar)

 

if possible please explain with code snippet otherwise any help will be appreciated.

 

Thank you very much. 

Please use plain text.
Administrator
MSohm
Posts: 14,517
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: List of CheckBox ( within fixed area ) should scroll vertically

You could add a number of CheckboxFields to a VertialFieldManager that has the Manager.VERTICAL_SCROLL  and Manager.VERTICAL_SCROLLBAR styles set.

 

Or you could use a ListField like what is done in this sample.

 

How To - Create a ListField with check boxes 
Article Number: DB-00471

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: List of CheckBox ( within fixed area ) should scroll vertically

Mark's answer left open the question of how to restrict the size of the VerticalFieldManager to 3.

 

Following is a suggested snippet that might help.  However in my playing round I have been unable to screen the scroll bars to display.  Any help with getting these displayed would be appreciated.

 

VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLLBAR | Manager.VERTICAL_SCROLL) { int maxHeight = this.getFont().getHeight() * 3; public int getPreferredHeight() { return this.getFont().getHeight() * this.getFieldCount(); } protected void sublayout(int width, int height){ super.sublayout(width, height); setExtent(width, Math.min(maxHeight, this.getPreferredHeight())); } };

 

Please use plain text.
Developer
naveensh
Posts: 51
Registered: ‎09-18-2008
My Device: Not Specified

Re: List of CheckBox ( within fixed area ) should scroll vertically

Thanks for your response.. 

 

I am extending screen class

 

I need to put Scrollbarbackground and scrollbar images .

 

after this button  is added to this screen. now i am not able to view button only list is displaying ..

 

 

The added button should show on the screen below the list on the screen ,it should not scroll with the list and it should viewable on the screen.

 

My point is list or checkbox can scroll ().button(i added after that with diff manager) should be viewable every time on the screen ..

 

 

If You send source code  i wil be great full to u..

 

 

Thanks in advance...

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: List of CheckBox ( within fixed area ) should scroll vertically

Sorry I didn't make my code snippet clear.

  

You should add your checkboxes to the vfm given above, and add the vfm to the screen.  Then add your button to the screen.  So now your screen has a section that scrolls and displays only 3 fields at once, followed by the button.

 

If you add things to the screen before you add the vfm, then they will be above the scrolling area. 

 

I don't understand your comment about Scrollbarbackground and scrollbar images, but I think that the above will answer your question anyway.

Please use plain text.
Developer
naveensh
Posts: 51
Registered: ‎09-18-2008
My Device: Not Specified

Re: List of CheckBox ( within fixed area ) should scroll vertically

Its working fine thanks for your response...

 

 One more is I need to put a scrollbar  images on the right side of the list.(just like normal scroll it should sync with the list) 

 

 

If u provide code, I will be greatful to u..

 

Thanks

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: List of CheckBox ( within fixed area ) should scroll vertically

I would recommend that you stop asking for code in your posts.  People will provide snippets and code to illustrate points where needed. But there is little value in providing source, because then people, like yourself, just learn how to cut and paste and won't learn how to program the BlackBerry.  More importantly, if you don't understand the code enough to write it, then you probably don't understand the code well enough to debug it.

 

If you really want code, then offer to pay for it and get it done properly. 

 

Regarding the scroll bars, if you re-read the post in which I supplied the vfm, you will see that I had noted that I couldn't get the scroll bars to work and I asked for help.  I suggest you wait for someone to respond to that (remember North America hasn't woken up yet).  If you don't get a response in a few days, then start another Thread and ask the question separately. 

Please use plain text.
Developer
Amit_K
Posts: 135
Registered: ‎08-27-2008
My Device: Not Specified

Re: List of CheckBox ( within fixed area ) should scroll vertically

I have created the List with checkField using the sample code . But I have to increase the spacing in between consecutive rows. How to do that ? here is my code snippet

 

public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
        //Get the ChecklistData for the current row.
        ChecklistData currentRow = (ChecklistData) listElements.elementAt(index);
        String text = currentRow.getStringVal();
       
        if (currentRow.isChecked()) {
            g.drawBitmap(0, y, checkedImage.getWidth(), checkedImage.getHeight(), checkedImage, 0, 0);
            g.setColor(Color.WHITE);
            g.drawText(text, checkedImage.getWidth() + 10, y, 0, w);
        } else {
            g.drawBitmap(0, y, uncheckedImage.getWidth(), uncheckedImage.getHeight(), uncheckedImage, 0, 0);
            g.setColor(Color.WHITE);
            g.drawText(text, checkedImage.getWidth() + 10, y, 0, w);
        }
    }

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: List of CheckBox ( within fixed area ) should scroll vertically

No need to double post or hi-jack threads!

 

Reponse posted to your other thread:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=6118

Please use plain text.