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
Trusted Contributor
sowjanya1919
Posts: 108
Registered: ‎08-21-2012
My Device: Blackberry curve
My Carrier: company
Accepted Solution

picturescrollfield

i am using the picturescrollfield to list a group of image in a horizontal scroll. Now i want a black semi transparent

image and some lines of code upon that each image ....with label option of  scrollentry i can place only a single

line...i want multiple line of text and that too with different font. Can any help me to do this.

Please use plain text.
Regular Contributor
meghana_datar
Posts: 56
Registered: ‎11-24-2010
My Device: Not Specified

Re: picturescrollfield

You can d this by adding PictureScrollField to Manager .

Try out following steps:

1)Create horizantalManager and override the sublayout. The field xpos and ypos should be set as per the xpos and ypos of picture scroll field.

for eg: picture scroll field is added vertically center. So the your field ypos = getPreferredHeight() /2 - fieldHeight/2;

xpos = getPreferredWidth()/2 - fieldWidth/2;

This will place you field exactly to center of your screen . 

2) Add labels with various font to this manager .

3) set the semi tranparent image as background to this manager.

4) Add picture scroll field to this manager.

 

Please use plain text.
Trusted Contributor
sowjanya1919
Posts: 108
Registered: ‎08-21-2012
My Device: Blackberry curve
My Carrier: company

Re: picturescrollfield

Thanks ....it working now...your hint gave me the one what i want for my app.

Please use plain text.
New Contributor
geervani
Posts: 5
Registered: ‎02-23-2011
My Device: Not Specified

Re: picturescrollfield

Hi Meghana,

 

Even I have the same requirement. I need multiline text to be dispalyed below the image in the PictureScrollField. Now the text is getting cut-off & displaying only one line. 

 

When you say "2) Add labels with various font to this manager .", you mean, label control to be added to Horizontal field manager? and PictureScrollField also added to horizontal field manager

 

Please advise.

 

Thanks in advance

Please use plain text.
Trusted Contributor
sowjanya1919
Posts: 108
Registered: ‎08-21-2012
My Device: Blackberry curve
My Carrier: company

Re: picturescrollfield

Yes, you have to override a manager where you have to define two fields ...In one field you just keep the horizontal manager in  which you have kept picturescollfied and in the other field you have to define anothe vertical manager which contains as many label field you want....Finall the set the size of first field to maximum and for second one

as you require....then set the position of first field to (0,0) and second to some other .

Please use plain text.
New Contributor
geervani
Posts: 5
Registered: ‎02-23-2011
My Device: Not Specified

Re: picturescrollfield

Thanks for the quick reply,  if the label is outside the picturescollfied, will the content change when the image in picturescollfied is changing?

Please use plain text.
Trusted Contributor
sowjanya1919
Posts: 108
Registered: ‎08-21-2012
My Device: Blackberry curve
My Carrier: company

Re: picturescrollfield

no it will not change ....if u want to change then u have the override the paint of label

Please use plain text.
New Contributor
geervani
Posts: 5
Registered: ‎02-23-2011
My Device: Not Specified

Re: picturescrollfield

My requirement is to display a set of images in Picturescrollfield. Each image will have a description. when the image is changed, teh below text should alos change. 

 

But the description in a long. when i set label in the picturescrollfield, the content in getting cutoff. Any solution for that!

Please use plain text.
Trusted Contributor
sowjanya1919
Posts: 108
Registered: ‎08-21-2012
My Device: Blackberry curve
My Carrier: company

Re: picturescrollfield

first define a static manager like this:

class StaticManager extends Manager implements ScrollChangeListener, FocusChangeListener {
    
    public static int couponSelected=0;
    boolean scrollListenerSet = false;
    XYRect ourExtent = new XYRect();
    public FeatureStaticManager() {
        super( Manager.USE_ALL_HEIGHT);
    }

    public void paintBackground(Graphics g) {
        int currentBackgroundColor = g.getBackgroundColor();
        try {
            g.setBackgroundColor(0X00CCCCCC);
            g.clear();
        } finally {
            g.setBackgroundColor(currentBackgroundColor);
        }
    }
    
    protected void sublayout(int maxWidth, int maxHeight) {
        maxHeight = Display.getHeight()/2;
        if ( this.getFieldCount() != 2 ) {
            
        }
        VerticalFieldManager listFieldManager = (VerticalFieldManager) this.getField(0);
    
        super.layoutChild(listFieldManager, 360, 352);
        super.setPositionChild(listFieldManager, 0, 0);
        if ( listFieldManager.getHeight() < maxHeight ) {
            maxHeight = listFieldManager.getHeight();
        }
        VerticalFieldManager imgVert=(VerticalFieldManager) this.getField(1);
        super.layoutChild(imgVert, 360, 70);
        super.setPositionChild(imgVert,0, 282);
        setExtent(360, 352);
        
    }
    public void scrollChanged(Manager manager, int newHorizontalScroll, int newVerticalScroll) {
        this.invalidate(); // repaint everything....
    }

    protected boolean navigationMovement(int dx, int dy, int status, int time) {
//        
        return super.navigationMovement(dx, dy, status, time);
    }
    
    protected boolean touchEvent(TouchEvent message) {
        
        return super.touchEvent(message);
    }
 
    public void focusChanged(Field field, int eventType) {
        this.invalidate();
        
    }
}

 

 

2nd step

=========

in your class:

define two vertical managers:  in first manager define only picturescrollfield with now label;

in second vertical manager: define the label the heigth what you wand the adjust the position of secon in the

above staticmanager.


3rd step

==========

add the two vertical managers to staticmanager like this

StaticManager s=new StaticManager();

s.add(firstVert);
s.add(secondVert);

add(s);

 

Please use plain text.
Regular Contributor
meghana_datar
Posts: 56
Registered: ‎11-24-2010
My Device: Not Specified

Re: picturescrollfield

You can do it more easily by overriding the navigation click method.

 

1) Override navigation click 

2) Get the current index of image which is focasble.

3) Set text according to index.

 

Hope this helps. Sorry for late reply.

Please use plain text.