HorizontalFieldManager with ListCallback?

I use JDE 4.2.1 and adds the horizontal fields to ListCallback lines.  Currently, I replaced the ListCallback drawListRow method to allow an icon and 4 columns of data to add to each line:

g.drawBitmap(4,y+4,14,14,myBitMap,0,0);
g.drawText(_column1,20,y,0,w/2-w/4+2);
g.drawText(_column2,w/2-w/4+6,y,0,w/2-w/8-2);
g.drawText(_column3,w/2-w/8+2,y,0,w-w/8-9);
g.drawText(_column4,w-w/8-5,y,0,w);

It has forced me to perform substring on each of the channels of column to make sure that they overlap with the next column.  I think I need to use HorizontalFieldManager to add the columns in a more logical and more predictable manner (output seems ok on 8830, but not on Pearl, for example).  I also hope that HFM will provide automatic operations of substring and Add «...» "to the right of the field if a substring is shown.  Is this the case?  If someone can point me to an example of use of HorizontalFieldManager with ListCallback?

Agree with everything tbilisoft has said, I just wanted to add a few points:

(a) I usually divide the display in columns, in pixels width and then use graphics methods to display the data in these columns.  See the following post for an example:

http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=9247&query.ID=256...

(b) ListField uses a getPreferredWidth reminder to determine its width.  I've used this to reduce the width of a ListField.  I have never attempted to increase the width.  Maybe worth a try?

Tags: BlackBerry Developers

Similar Questions

  • List of the HorizontalFieldManager with scrolling focus problem

    Hello

    I'm doing a vertical list of horizontalfieldmanager with an icon and two text fields, but I'm having a problem when scrolling it. I used a nullField to manage focus. When I scroll to the top everything works well, but when I Ahmed to the bottom of the item appears on the edge of the screen.

    I guess that I did not understand how to manage the focusChange metodh and the metodh of the painting.

    All advice will be appreciated.

    Thank you, Andrea.

    //
        // Main screen for the application
        //
        private class MyMainScreen extends MainScreen
        {
            public MyMainScreen()
            {
                super(Manager.USE_ALL_WIDTH);
    
                for (int i = 0; i<20; i++) this.getMainManager().add(new PanelRow("off", "first text line", "second text line"));
            }
    
            private class PanelRow extends HorizontalFieldManager implements FocusChangeListener
            {
                private NullField nullField;
                private BitmapField icon;
                private ColorLabelField label1;
                private ColorLabelField label2;
    
                public PanelRow(String iconString, String label1String, String label2String)
                {
                    super(Manager.USE_ALL_WIDTH);
    
                    // Add null field
                    nullField = new NullField(NullField.FOCUSABLE);
                    nullField.setFocusListener(this);
                    super.add(nullField);
    
                    // Add bitmap
                    Bitmap offIcon = Bitmap.getBitmapResource("offButton.png");
                    icon = new BitmapField(offIcon, BitmapField.NON_FOCUSABLE | BitmapField.FIELD_LEFT);
                    super.add(icon);
    
                    // Add first and second text lines
                    VerticalFieldManager labelsVerticalManager = new VerticalFieldManager();
                    label1 = new ColorLabelField(label1String, LabelField.NON_FOCUSABLE | LabelField.FIELD_LEFT);
                    label2 = new ColorLabelField(label2String, LabelField.NON_FOCUSABLE | LabelField.FIELD_LEFT);
                    labelsVerticalManager.add(label1);
                    labelsVerticalManager.add(label2);
                    super.add(labelsVerticalManager);
                }
    
                public void focusChanged(Field field, int eventType)
                {
                    invalidate();
                }
    
                protected boolean navigationClick(int status, int time)
                {
                    fieldChangeNotify(FieldChangeListener.PROGRAMMATIC);
    
                    return true;
                }
    
                protected void paint(Graphics g)
                {
                    int oldBackground = g.getBackgroundColor();
    
                    if (nullField.isFocus())
                    {
                        g.setBackgroundColor(Color.CADETBLUE);
    
                        label1.setFontColor(Color.WHITE);
                        label2.setFontColor(Color.WHITE);
                    }
                    else
                    {
                        g.setBackgroundColor(Color.WHITE);
    
                        label1.setFontColor(Color.SLATEGRAY);
                        label2.setFontColor(Color.BLACK);
                    }
    
                    g.clear();
    
                    g.setBackgroundColor(oldBackground);
    
                    super.paint(g);
                }
            }
    
            //
            // Define a new colored labelfield class
            //
            public class ColorLabelField extends LabelField
            {
                public ColorLabelField(Object text, long style)
                {
                    super(text, style);
                }
    
                private int mFontColor = -1;
    
                public void setFontColor(int fontColor)
                {
                    mFontColor = fontColor;
                }
    
                protected void paint(Graphics graphics)
                {
                    if (-1 != mFontColor) graphics.setColor(mFontColor);
    
                    super.paint(graphics);
                }
            }
        }
    

    Then try to create your NullField with getFocusRect override: like this:

    nullField = new NullField(NullField.FOCUSABLE) {
      public void getFocusRect(XYRect rect) {
        getManager.getExtent(rect);
        rect.setLocation(0, 0);
      }
    };
    

    Paint won't help you - you must tell the system to the entire span developed in order to scroll properly. If the above fails, analyze your focusChanged eventType and make sure that your Manager is fully visible on the screen on FOCUS_GAINED. To do this, you need to use getManager () .getVerticalScroll () / getManager () .setVerticalScroll () as well as of your Manager and getHeight() getTop().

  • HorizontalFieldManager Fix width automatic measurement with height

    Hi all

    I would like to make a HorizontalFieldManager with a fixed width, but automatic measurement with height. Do anyone with a good idea about it. Thanks for the help!

    Thanks for your help!

    Although your idea is a solution is not complete, it gives me a good idea to solve the problem.
    My solution is to change my coding over a part of the first horizontalfieldmanger:

    HorizontalFieldManager hfm1 = new HorizontalFieldManager()

    {

    public int getPreferredWidth()

    {

    Returns the value 100;

    }

    protected void sublayout (int maxWidth, maxHeight int) {}

    Super.sublayout (getPreferredWidth(), maxHeight);

    LeftField RadioButtonField = getLeftButton();

    If (leftField! = null & is equal to (leftField.getManager ())) {}

    int x = 0;

    int y = 0;

    setPositionChild (leftField, x, y);

    }

    }

    };

  • Two RadioButton on the same line with any idea...

    Hello

    Can I add two RadioButton singel online...

    I m using HorizontalFieldManager with him

    but only the first button is visible... give me a solution simple and good for this please help me.

    Thank you

    Himanshu

    Beginner

    Please find the Code below and try it and let me know...

    radioButtonGroup = new RadioButtonGroup();
    
            radioButtonField = new RadioButtonField("Radio 1", radioButtonGroup,
                    true, 0) {
                protected void layout(int arg0, int arg1) {
                    setExtent(Display.getWidth() / 2, arg1);
                    super.layout(Display.getWidth() / 2, arg1);
                };
            };
            radioButtonField1 = new RadioButtonField("Radio 2", radioButtonGroup,
                    false, 0) {
    
                protected void layout(int arg0, int arg1) {
                    setExtent(Display.getWidth() / 2, arg1);
                    super.layout(Display.getWidth() / 2, arg1);
                };
    
            };
    
            HorizontalFieldManager hfmFieldManager = new HorizontalFieldManager() {
                protected void sublayout(int maxWidth, int maxHeight) {
                    setExtent(Display.getWidth(), maxHeight);
                    super.sublayout(Display.getWidth(), maxHeight);
                }
            };
    
            hfmFieldManager.add(radioButtonField);
            hfmFieldManager.add(radioButtonField1);
    
            add(hfmFieldManager);
    
            add(new LabelField("This label is below the two radio buttons",FOCUSABLE));
            add(new ButtonField("Click ME!"));
    
  • How to remove ButtonField when the user has clicked and it is in HorizontalFieldmanager...

    Hello
    My screen I have the list of data and at the end I buttons when I click the button, the data should remain and should be deleted. My screen I have a VerticalFieldManager and given I have place in HorizontalFieldManager and I added the button horizontalFieldmanager.even I place in HorizontalFieldmanager... to be more detailed, I see: -.

    class Page extends Screen
        {
            LabelField name,namevalue,Phone,phoneNumber;
            ButtonField btn;
    
            Page()
            {
                              super(new VerticalFieldManager(),NO_VERTICAL_SCROLL);
    
                    VerticalFieldManager vfm_Data = new VerticalFieldManager(Field.USE_ALL_WIDTH | VerticalFieldManager.VERTICAL_SCROLL | VerticalFieldManager.VERTICAL_SCROLLBAR);
    
                                         HorizontalFieldManager hfm_name = new HorizontalFieldManager();
                     name = new LabelField("Name     :     ");
                     hfm_name.add(name);
    
                                         namevalue = new LabelField("Jackey");
                     hfm_name(namevalue);
                               vfm_Data.add(hfm_name);          
    
                                HorizontalFieldManager hfm_phone = new HorizontalFieldManager();
                     Phone = new LabelField("Contact Number     :     ");
                     hfm_phone.add(name);
    
                                         phoneNumbere = new LabelField("123456");
                     hfm_phone(phoneNumber);
                                vfm_Data.add(hfm_phone);
    
                   //Like above HorizontalFieldManager i have 10 more say HorizontalFieldManager with Data and value and i have added all the HorizontalField Manager to VericalFieldManager vfm_Data....and i have a button in the end :
    
                HorizontalFieldManager hfm_button= new HorizontalFieldManager();
                btn = new ButtonField("Accepted");
                hfm_button.add(btn);
                vfm_Data.add(hfm_button);
    
                //and at i add the verticalField manager.
    
                add(vfm_data);
    

    My requirement is now when I click on the button accept I want to delete field button that I do a delete (hfm_button);   , But it says an error "Attempt to delete a field that does not belong to the Manager."

    Can you please tell me how to delete the field button when I click on the button accept...

    First your VFM is named vfm_Data, and at the end your constructor you add a (nonexistent) value to the screen named vfm_data.

    Have you tried vfm_Data.delete (hfm_button)?

  • Header with images on the edges of the screen

    Hello

    I would like to create a header for my screen in which I have a logo on the left side and another on the right edge of the screen.

    I put my pictures in a HorizontalFieldManager with Left and Right style (I tried beginning and end) but their still glued together. I tried to do it with verticalFieldManagerS (left, leading options and redefine the paint method) in the HorizontalFieldManger but no effect.

    You have an idea?

    Thank you

    Thank you guys, I found a way to do it.

    I'd go the HorizontalManagerField class and then override the sublayout method.

    I must make a delicate calculation but it works...

  • move the focus from the field to the Manager

    Help!

    I have a HorizontalFieldManager with some fields inside. When I touch on the hfm, I want that he win the tune-up. Everything is fine with the BlackBerry without a touchscreen. I can scroll all hfms.

    But when I touch on the subject of the focus in the hfm gain the focus and not the hfm. How can I change?

    When I want to get the Manager on the ground and give it focus that nothing changes. Call this.setFocus () in the manager didn't make when press the subject field of the focus. When I touch outside the scope of field, everything is fine!

    I have no idea!

    Can someone help me please?

    Concerning

    When the fields are non-Focus, you can still have a NullField focusable.

    a non-trivial alternative might be to manually indicate the development of the manager through the methods onFocus() and onUnFocus() of the field that is getting the focus

  • Only a VerticalFieldManager in scroll screen

    Hello

    I have a class that extends the screen. This screen contains a HorizontalFieldManager with a nested VerticalFieldManager. The VerticalFieldManager is set to scroll. I want to do the VerticalFieldManager with scrolling to the point where the VerticalFieldManager is the ONLY thing that scrolls. Currently, the entire screen will scroll.

    I was able to do this successfully by the extension "PopupScreen" instead of "Screen" and to the specification in the constructor:

    super(new VerticalFieldManager(NO_VERTICAL_SCROLL | NO_VERTICAL_SCROLLBAR),Field.FOCUSABLE);
    

    However, it is not good, because I need to use the setStatus() method, which I believe is that by extending the screen accessible.

    Is there anyway that I can achieve everything by extending the screen and having access to setStatus()?

    Thank you!

    Solved with super (NO_VERTICAL_SCROLL);

  • Horizontal and vertical field centered group

    Hello

    I have a form of the screen with two editFields and a button. I want to do is make them one under the other in the middle of the screen, appears as in this photo:

    I tried to use 3 HorizontalFieldManager with

    Manager.

    FIELD_VCENTER.  inside a VerticalFieldManager created with Manager.USE_ALL_WIDTH style, but the fields will appear on the top of the screen and they take the entire width of the screen.

    As the Senior Manager of your screen is VerticalFieldManager (you use screen, are you not?), it will ignore (understandable) flags the child fields FIELD_VCENTER. However, it will honor all horizontal alignment as FIELD_HCENTER indicators. However, FIELD_HCENTER not play with USE_ALL_WIDTH, so drop it. HorizontalFieldManager does not honor FIELD_VCENTER his children - you will use it to take advantage of this fact.

    This may seem a bit complicated at first, so I'll give you more details:

    (1) create your screen with the explicit NO_VERTICAL_SCROLL style bit (important!)

    (2) add a HorizontalFieldManager(USE_ALL_WIDTH |) USE_ALL_HEIGHT) on the screen--let's call is bigHFM

    (3) add a VerticalFieldManager(USE_ALL_WIDTH |) FIELD_VCENTER) to bigHFM - we will call this new bigVFM Manager

    (4) create a HorizontalFieldManager (FIELD_HCENTER) - Let's call it firstRow - and add it to bigVFM

    (5) in the same way, create a HorizontalFieldManager (FIELD_HCENTER) called secondRow and add it to bigVFM

    (6) add LabelField ("Label 1") and a text field to firstRow

    (7) add LabelField ("Label 2") and a further edition in secondRow field

    (8) create a ButtonField ("Button", FIELD_HCENTER) and add it to bigVFM

    (9) to run the application, look at the screen, change the borders of fields if you want and enjoy!

    P.S.: Although Field.setMargin is documented in the 6.0, it works like that since at least 4.2.0

  • Issue of bottom paint for horizontal scrolling

    Hello

    I have a HorizontalFieldManager with a gradient background which I've updated to enable horizontal scrolling. Scrolling works well, but the gradient background is not painted when scrolling to the right. Using trial and error "getHorizontalScroll()" to calculate and offset has not yet failed.

    The original code is lower for horizontal management.

    ...
        hm = new HorizontalFieldManager(hmStyle) {
          protected void paint (Graphics g) {
            g.clear();
            g.setBackgroundColor(bgColor);
            int[] xInds = new int[]{0, 0,getExtent().width, getExtent().width};
            int[] yInds = new int[]{0, getExtent().height, getExtent().height,0};
    
            final int[] cols = new int[]{bgColor, gradientColor, gradientColor, bgColor};
    
            g.drawShadedFilledPath(xInds, yInds, null, cols, null);
            super.paint(g);
          }
          protected void onFocus(int arg0) {
            super.onFocus(arg0);
            getScreen().invalidate();
          }
        };
    ...
    

    I know I'm probably not set up the xInds properly to compensate for offset from horizontal scrolling, but it's not obvious to me how to set up the offsets correctly. Can anyone offer a suggestion to troubleshoot? If not, is there a reference to certain documents which provides more detail than the docs of java on the functioning of the 'drawShadedFilledPath' and the logic of ScrollBar?

    Thanks in advance!

    int xstart = getHorizontalScroll();
    int xend = xstart + getVisibleWidth() - 1; // getWidth() is also good
    int[] xInds = new int[]{xstart, xstart, xend, xend};
    
  • How to set the background color to the Manager?

    I'm working on JDE 4.2.1

    I have a HorizontalFieldManager with fields like this.

    HorizontalFieldManager titleManager = new HorizontalFieldManager (HorizontalFieldManager.FIELD_HCENTER);

    Bitmap image = Bitmap.getBitmapResource("images/test.png");
    BitmapField myBitmapField = new BitmapField (image);

    titleManager.add (myBitmapField);

    titleManager.add (new LabelField ("Documents"));

    MY requirement is to have the background color as blue titleManager. This titleManager is inside another Director.

    If I want to customize, how can I do it?

    Thanks for any help.

    crush paintBackground
    use graphics.setColor and graphics.fillRect to paint you like.

  • AbsoluteFieldManager inside another Manager

    Hello. I'm trying to place my AbsoluteFieldManager inside another Manager. Basically, I want my absManager at the bottom of the screen (like setStatus). I couldn't find a way to achieve this properly so I created a HorizontalFieldManager, setStatus (hManager) and now I wanted to add the absManager to hManager but it gives me an error saying that it is already apparent.

    What I'm trying to do, is have a bar of tabs at the bottom of the screen, what I did with success in using hManager. The thing is that I want to place my tabs where I want.

    Any help would be greatly appreciated.

    Thank you.

    I just setPadding instead of setMargin and it works. Background image of the horizontalFieldManager seems to stop at the margin, so the margin of a HorizontalFieldManager with a background image the assignment will result in white space.

    Thanks for the help.

  • MainScreen.onDisplay (NullPointerException)

    I have a very simple application which is a screen with a HorizontalFieldManager, with some custom fields added.  The application is running, find and renders when I use the default style in the custom fields.  However, when I set the FOCUSABLE style on custom fields, the application throws a NullPointerException (I think on a null defaultFocus element) in the my screen onDisplay method (called as a direct result of UiApplication.pushScreen ()).

    I develop on JDE 4.2.1 8800 Simulator.  Anyone has any ideas to help diagnose and fix?

    Thank you.

    I had read the docs of field and gave your suggestion to try.  What I found, was that isFocusable() on my custom fields was called.  But onFocus not was.  I had an onFocus() in Manager containing fields, though.  I took a look at it and noticed that he had only a message of newspaper inside.  For some reason, I had neglected to make the call to super.onFocus ().  And that was the problem.  When I added that back in (and in fact, removed the substitution at the level of the Manager altogether), the exception went, and everything started working again.

    Thanks for the help.

  • Newbie: Difference between DrawStyle.attr and FIELD.attr

    For example, there is Field.FIELD_HCENTER and DrawStyle.HCENTER, and, of course, LabelField inherits both.  If I want to Center a field (that I do, surprisingly enough ;-), I build a HorizontalFieldManager with specified Field.FIELD_HCENTER (or USE_ALL_WIDTH, I think).  Then I do a LabelField to go inside and, although there are a lot of examples out there on the internet about this, some of them build the LabelField with DrawStyle.HCENTER and some build with Field.FIELD_HCENTER, which leads to two questions:

    1. which is correct for this specific use, and

    2. for academic gratification, which is the generalization, or rule, for each?

    TIA,

    Allen

    The text is not centered because titField is placed to the left of the titMan and is not as wide as necessary to the text. I see three corrections:

    1. Replace HCENTER by FIELD_HCENTER in the style for titField (this will tell titMan Center titField;) HCENTER is without effect since titField continues to be wide enough for the text);
    2. Add USE_ALL_WIDTH to the style for titField (this will tell titMan do titField full width; text will then be centered because HCENTER);
    3. (my favorite) eliminate the use of titMan, who isn't really add all features:
    public void setTitle(String title) {    titField = new LabelField(title, HCENTER | ELLIPSIS | USE_ALL_WIDTH);    titField.setFont(titField.getFont().derive(Font.UNDERLINED));    man.add(titField);}
    

    (Of course, if you need titMan for other reasons, with a stick from the first two.)

    P.S.: If you declare the enclosing as 'implements DrawStye' class, you need not to qualify all of these constants.

  • Doubts in HorizontalScrolling

    Hi guys, I have a horizontalfieldManager, with 10 labels of fields added in, but in the device, I see only certain no. fields in it, but the problem I encounter in the way to display the labels fields that are not visible in the camera, how to make floating in touch devices?

    your ideas in it?

    Hi guys, I deleted it,

    I implements the touchEvent method after the aft of the method, now it may be the object of a scroll.

    Concerning

    Rakesh Shankar.P

Maybe you are looking for