09-22-2008 11:01 AM
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.
09-22-2008 05:35 PM
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
09-22-2008 08:39 PM
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())); } };
09-23-2008 01:05 AM
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...
09-23-2008 04:17 AM
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.
09-23-2008 04:46 AM
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
09-23-2008 05:39 AM
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.
09-30-2008 05:14 AM
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);
}
}
09-30-2008 06:36 AM
No need to double post or hi-jack threads!
Reponse posted to your other thread:
http://supportforums.blackberry.com/rim/board/mess