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
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified
Accepted Solution

Only 108 choices displying on Storm out of 164

Hi friends,

 

I have created one simple screen using jde 4.7.0 and displying ObjectChoice field on it. Choice string array is hardcoded by 164 strings. But only 108 strings out of them are displying in objectChoiceField.

 

Plese help me where I m missing. My code is

 

private ObjectChoiceField getChoiceField(String[] str) {
        return new ObjectChoiceField("", str, 0, Field.FIELD_VCENTER | Field.FIELD_LEFT | Field.EDITABLE) {

            protected void layout(int width, int height) {
                width = CHOICEFIELD_WIDTH;
                height = CHOICEFIELD_HEIGHT;
                super.setExtent(width, height);
            }
        };
    }

 

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

Re: Only 108 choices displying on Storm out of 164

I wasn't able to reproduce this using the default ObjectChoiceField.  Do you see the same behaviour when not overriding any methods?  What are the width and height values you are using?

 

What is the full 4 digit BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

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
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Only 108 choices displying on Storm out of 164

When I m declaring the string array in one class and fetching that using method, I m getting the follwoing problem. If I directly set the string array values to the object choice field, all choices are displying correctly.

 

Means it is some code problem.

Thanks for your replay.

Please use plain text.
Developer
baskaraninfo
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: Only 108 choices displying on Storm out of 164

After getting the String array from the other class, please check whether it has all 164 choices before setting to Object choice field.

Use Search. "Accept Solution" if the problem gets resolved.
Please use plain text.
New Developer
perlwhite
Posts: 122
Registered: ‎07-28-2009
My Device: Not Specified

Re: Only 108 choices displying on Storm out of 164

Hi i am trying to diaplay a ObjectChoiceField where in the Choices String array i have a data which contains 8 to 10 words...but when  i try to display i am unable to diaplay all the words some words are not displayed completly it displays lie Wo... kindly give  valuable suggestion to diaply the entire text in ObjectChoiceField
Please use plain text.
New Developer
perlwhite
Posts: 122
Registered: ‎07-28-2009
My Device: Not Specified

Re: Only 108 choices displying on Storm out of 164

I am using JDE 4.5 and default simulator of it...
Please use plain text.
Developer
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Only 108 choices displying on Storm out of 164

Just check the output after overriding layout methos of objectChoiceField like

 

 

protected void layout(int width, int height) {

           width = managerWidth;

          height =this.getFont().getHeight();

          //uses the super class' layout functionality

        //after the width and the height are set

         // super.layout(width, height);

         super.setExtent(width, height);

}

 

my code is working fine with this, previously I was also facing the same problem, but when I commented super.layout(..) method, it's working. I did not understand logic behind this.

 

Please use plain text.
New Developer
perlwhite
Posts: 122
Registered: ‎07-28-2009
My Device: Not Specified

Re: Only 108 choices displying on Storm out of 164

Can provide the entrire code for overiding the ObjectChoiceField i am unable to understand with only piece of code of it......
Please use plain text.
Developer
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Only 108 choices displying on Storm out of 164

I have customized by taking one arrow image at the right side of the objectchoicefield for better look and feel. Please add any available image and try the following code. This is developed in 4.2. And in 4.5 you can not use setMargin() method which I have used. You have to find out the solution for that.

 

 

package ui;

import net.rim.device.api.system.Bitmap;

import net.rim.device.api.ui.Color;

import net.rim.device.api.ui.Field;

import net.rim.device.api.ui.Font;

import net.rim.device.api.ui.Graphics;

import net.rim.device.api.ui.component.BitmapField;

import net.rim.device.api.ui.component.ObjectChoiceField;

import net.rim.device.api.ui.container.HorizontalFieldManager;

 

public class CustomComboBox extends HorizontalFieldManager {

/**

* define some variables to be used in the class

*/

private int managerWidth;

private int managerHeight;

private ObjectChoiceField choiceField;

 

private Bitmap bmpComboArrow;

private BitmapField bmfArrow;

public CustomComboBox(final String[] listValues, final int width) {

super();

bmpComboArrow = Bitmap.getBitmapResource("images/combo_arrow.png");

 

bmfArrow = new BitmapField(bmpComboArrow);

managerWidth = width;

managerHeight = bmpComboArrow.getHeight();

 

HorizontalFieldManager hfm = new HorizontalFieldManager() {

public void sublayout(int width, int height) {

width = managerWidth + bmpComboArrow.getWidth();

height = bmpComboArrow.getHeight();

super.sublayout(width, height);

super.setExtent(width, height);

// setPosition(0, 3);

}

protected void paint(Graphics graphics) {

if (choiceField.isFocus()) {

graphics.setColor(Color.NAVY);

} else {

graphics.setColor(Color.WHITE);

}

graphics.fillRect(0, 0, getWidth(), getWidth());

invalidate();

super.paint(graphics);

}

};

 

choiceField =new ObjectChoiceField("", listValues, 0,Field.FIELD_VCENTER| Field.FIELD_LEFT | Field.EDITABLE ) {

 

 

public void paint(Graphics graphics) {

 

graphics.setFont(Font.getDefault().derive(Font.BOLD, 12));

if (this.isFocus()) {

graphics.setColor(Color.WHITE);

graphics.setBackgroundColor(Color.NAVY);

} else {

graphics.setColor(Color.BLACK);

graphics.setBackgroundColor(Color.WHITE);

}

graphics.clear();

// graphics.drawText(listValues[this.getSelectedIndex()], 2, (getWidth() - this.getFont().getHeight()) >> 1);

 

// invalidate();

super.paint(graphics);

}

protected void layout(int width, int height) {

width = managerWidth;

height =this.getFont().getHeight();

//uses the super class' layout functionality

//after the width and the height are set

// super.layout(width, height);

super.setExtent(width, height);

}

};

int top =(bmpComboArrow.getHeight()- choiceField.getFont().getHeight())>>1;

// choiceField.setMargin(top, 0, top, 0);

choiceField.setPadding(top, 0, top, 0);

hfm.add(choiceField);

hfm.add(bmfArrow);

// hfm.setMargin(5, 0, 5, 0);

add(hfm);

 

}

 

public int getSelectedIndex() {

return choiceField.getSelectedIndex();

}

public void setSelectedIndex(int index) {

choiceField.setSelectedIndex(index);

}

 

public void setChoices(Object[] choices){

choiceField.setChoices(choices);

}

public void setFont(Font font){

choiceField.setFont(font);

}

 

}

 

Please use plain text.
New Developer
perlwhite
Posts: 122
Registered: ‎07-28-2009
My Device: Not Specified

Re: Only 108 choices displying on Storm out of 164

I mean the code to change the color of choices in ObjectChoiceField.......we need to customise the ObjectChoiceField, can u provide me help for customising ObjectChoiceField
Please use plain text.