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
Highlighted
New Contributor
Posts: 8
Registered: ‎05-01-2012
My Device: Blackberry 8520
My Carrier: Blackberry

layout managers

Hi all,

 

i am trying to develop a program where in a picture scroller appears at the bottom of the mobile screen, but am not able to figure out layout managers, the screen appears just plain white. Please help,

 

Here is the code below for screen

 

public class MobiletvMainScreen extends MainScreen {

                 VerticalFieldManager Vfm;
                //HorizontalFieldManager Hfm;
                FieldManager fm = new FieldManager();

                 //Determine half of the screen Height.
                //int Sheight = Graphics.getScreenHeight() / 3;
                //int Swidth = Graphics.getScreenWidth();

                      MobiletvMainScreen() {

                               Vfm = new VerticalFieldManager(USE_ALL_WIDTH);

                            //Hfm = new HorizontalFieldManager(FIELD_BOTTOM);

                             Bitmap images[] = new Bitmap[9];
                             String[] labels = new String[9];
                               String[] tooltips = new String[9];

                        


ScrollEntry[] entries= new ScrollEntry[9];

for (int i = 0; i < entries.length; i++)
{
imgIndex = i+1;


images[i] = Bitmap.getBitmapResource("resource/pic" + imgIndex+ ".png");

labels [i] = "Label for image" + imgIndex;

 

tooltips[i] = "Tooltips for image" +imgIndex;


entries[i] = new ScrollEntry(images[i], labels[i], tooltips[i]);

}

PictureScroll pictureScroll = new PictureScroll(entries);


fm.add(pictureScroll);


Vfm.add(fm);


add(Vfm);




}



private class PictureScroll extends PictureScrollField {

private final ScrollEntry[] _entries;

PictureScroll(ScrollEntry[] entries) {


super(200,327);

_entries = entries;


this.setImageDistance(50);


this.setData(entries, 0);

this.setHighlightStyle(HighlightStyle.ILLUMINATE_WITH_MAGNIFY_LENS);


this.setHighlightBorderColor(Color.BLUE);
}
}



}

 

Here is the Fieldmanager Class

 

public class FieldManager extends Manager{



FieldManager() {

super(FIELD_BOTTOM);

}


//int Swidth = Graphics.getScreenWidth();


//int Sheight = Graphics.getScreenHeight()/3;

protected void sublayout(int width, int height) {


//if (getFieldCount() > 0) {


Field centeredField = getField(0);


layoutChild(centeredField, getPreferredwidth(), getPreferredheight()); 


setPositionChild(centeredField,getPreferredwidth(), getPreferredheight() );  


setExtent(Graphics.getScreenWidth(), Graphics.getScreenHeight()/2); 

}

New Developer
Posts: 60
Registered: ‎09-23-2011
My Device: Blackberry
My Carrier: Blackberry Developer

Re: layout managers

Hello ,

 

If you required to add the contents in botton of screen.

 

Then add your content in vfm in your code and replace add(vfm) as a setStatus(vfm).

 

 

Please tell me my solution is work or not.

New Contributor
Posts: 8
Registered: ‎05-01-2012
My Device: Blackberry 8520
My Carrier: Blackberry

Re: layout managers

thanks Aniruddha...  but its not working. Smiley Sad(

New Developer
Posts: 60
Registered: ‎09-23-2011
My Device: Blackberry
My Carrier: Blackberry Developer

Re: layout managers

Hello Henna,

 

Please try this code it works properly. It is solve your issue. Picture scroll field set at the bottom of screen.

 

package mypackage;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.extension.component.PictureScrollField;
import net.rim.device.api.ui.extension.component.PictureScrollField.ScrollEntry;

public class MobiletvMainScreen extends MainScreen {
    MobiletvMainScreen() {
        Bitmap images[] = new Bitmap[9];
        String[] labels = new String[9];
        String[] tooltips = new String[9];

        ScrollEntry[] entries = new ScrollEntry[9];

        for (int i = 0; i < entries.length; i++) {
            int imgIndex = i + 1;
            images[i] = Bitmap.getBitmapResource("first.png");// ("res/pic" +
                                                                // imgIndex +
                                                                // ".png");
            labels[i] = "Label for image" + imgIndex;
            tooltips[i] = "Tooltips for image" + imgIndex;
            entries[i] = new ScrollEntry(images[i], labels[i], tooltips[i]);
        }
        PictureScroll pictureScroll = new PictureScroll(entries);
        add(pictureScroll);
    }

    private class PictureScroll extends PictureScrollField {
        private final ScrollEntry[] _entries;

        PictureScroll(ScrollEntry[] entries) {
            super(100, 100);
            _entries = entries;
            this.setImageDistance(70);
            this.setData(_entries, 0);
            this.setHighlightStyle(HighlightStyle.ILLUMINATE_WITH_MAGNIFY_LENS);
            this.setHighlightBorderColor(Color.BLUE);
            this.setPadding(250, 0, 0, 0);
        }
    }
}

 

Thanks!!

Regards,

Aniruddha

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: layout managers

check the samples at
http://supportforums.blackberry.com/t5/Java-Development/Implement-advanced-buttons-fields-and-manage...
maybe there is something that helps you out
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 60
Registered: ‎09-23-2011
My Device: Blackberry
My Carrier: Blackberry Developer

Re: layout managers

Hello ,

 

If you want to set using custom layout manager then please refere below link.

 

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

 

Thanks!!

Regards,

Aniruddha

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: layout managers