EditField + BitmapField in a horizontalfield Manager

Hello

I use code below to show a field of editing and Bitmap in a horizontal field Manager, but I'm getting illegal state exception...

If I first add BitmapField and then change the field it works fine but I need Editifield first and then BitmapField

Below is my code...

  Bitmap bg = Bitmap.getBitmapResource("twenty.png");
  locations = new BitmapField(bg,bg,"Locations");
  EditField table=new EditField("Ticket No : ","",5,EditField.FILTER_NUMERIC)
         {
                private int iRectX = getFont().getAdvance(getLabel());
                private int iRectWidth = Display.getWidth() - iRectX - 4;
                public void paint(Graphics g)
                 {
                            g.setColor(0x000000);
                            g.drawRect(iRectX, 0, 170, 18);
                            super.paint(g);
                }
         };

  HorizontalFieldManager hfm=new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
  hfm.add(locations);
  hfm.add(table);
  add(hfm);

I already tried taking two horizontal field to add the edit field in the image in another Manager and added these two leaders in vertical field but no luck...

I also tried traced table...

EditFields use the full available width.
You can crush getPreferredWidth or use a custom presentation:
http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800508/...

Tags: BlackBerry Developers

Similar Questions

  • Alignment editfields & bitmapfield using managers

    Hello

    I am the creation of screen which has 4 editfields basic and in the an of the fundamental change field I want to add a question mark image (which is a field that is focusable)

    all editfields have a limit of 64 characters, and it will not allow NEW_LINE (so NEW_NEWLINE)

    The arrangement is as follows

    basicedit1: aaa

    basicedit2: bbbb?

    basicedit3: ccccc

    basicedit4: ddddd

    I use a horizontal for the basicedit2 Manager & the question mark field.

    This Manager and other areas of the basic edition are added to the vertical field Manager

    The problem is when I enter 64 char basicedit1 (when the w & m when the tank move to the new line) moving the image to the left. How can I avoid this in basic edit2 the tank behind the image?

    How can I implement this better

    You could add a pair of VerticalFieldManagers to the HorizontalFieldManagers that make your line for a column as layout within each line.

  • Key events on the fields in the custom horizontalfield Manager

    Hi all

    I created the screen with a title bar and toolbar.

    The toolbar is created with a HorizontalFieldManager.

    Toolbar contains three BitmapField and a LabelField.

    How can I manage the key events of the fields in the HorizontalFieldManager.

    Where I need to override the keyChar() method.

    I did something wrong here. I do not receive the dialog box by pressing the Enter key. It is moving to the next icon that's all.

    I can move each icon by using the arrow keys, it is also developed. But when I press the Enter key, it goes to the next icon.

    I want to show the new screen by pressing the Enter key on each icon in the HorizontalFieldManager.

    How can I solve this problem... Any help...

    Override KeyDown() in your screen. As:

        public boolean keyDown(int keycode, int time)
        {
            System.out.println("Enter key pressed!");
            if (icon1.isFocus())
                Dialog.inform("show page1");
            else if (icon2.isFocus())
                Dialog.inform("show page2");
            else
                Dialog.inform("show page3");
    
            return true;
        }
    

    Concerning

    Bika

  • Addition of two basicEditFields in HorizontalField Manager

    I try to add two basic change fields in a Horizontal field Manager. But, I don't know why, that one field is in veiw cannot see the second field anywhere. Here is the code I use:

     HorizontalFieldManager hfm ;
        VerticalFieldManager signUpMngr;
        BasicEditField cc, number;
        int width = (((Display.getWidth()*25)/100)-20);
        public UserScreen() {
            cc = getBasicEditField(4, BasicEditField.FILTER_NUMERIC,width ,5, 5, 5, 5);
            number = getBasicEditField(11, BasicEditField.FILTER_NUMERIC,width ,5, 5, 5, 5);
    
            hfm = new HorizontalFieldManager(USE_ALL_WIDTH|NO_HORIZONTAL_SCROLL|NO_VERTICAL_SCROLL){
    protected void sublayout(int maxWidth, int maxHeight) {
        // TODO Auto-generated method stub
        super.sublayout(maxWidth, maxHeight);
        int count = getFieldCount();
        int x = 20;
        int y = 10;
        for (int i = 0; i < count; i++) {
        Field f = getField(i);
        layoutChild(f, f.getWidth(), f.getHeight());
        setPositionChild(f, x, y);
        x += cc.getWidth()+5;
        }
                       setExtent(Display.getWidth(),Display.getHeight());
       }
    };
        hfm.add(cc);
        hfm.add(number);
    
       signUpMngr = new VerticalFieldManager(USE_ALL_WIDTH | USE_ALL_HEIGHT | VERTICAL_SCROLL);
       signUpMngr.add(hfm);
    
       this.add(signUpMngr);
    }
    
    public BasicEditField getBasicEditField(final int size, final long style,final int fieldWidth, final int topPadding, final int rightPadding,final int bottomPadding, final int leftPadding) {
      BasicEditField field = new BasicEditField("", "", size, style) {
        protected void paint(Graphics graphics) {
               graphics.setColor(Color.GRAY);
           getFont().derive(Font.BOLD);
           super.paint(graphics);
        }
    
        protected void paintBackground(Graphics g) {
           g.setColor(Color.GRAY);
           g.drawRoundRect(leftPadding, 0, fieldWidth- (leftPadding + rightPadding), this.getHeight(), 12,14);
           super.paintBackground(g);
            }
      };
      field.setPadding(topPadding, rightPadding + 2, bottomPadding,
                    leftPadding + 2);
      return field;
     }
    

    Concerning

    Here's the answer to your problem:

    HorizontalFieldManager problem

  • to align the label Center field in horizontalfield Manager

    Hello world

    I have three field label inserting in horizontal field Manager, by default, it is show laft alignment.

    But I need to put all the Center horizontally.

    someone can help me.

    My code is given below

    HorizontalFieldManager curencyPrice = new HorizontalFieldManager (HorizontalFieldManager.FIELD_HCENTER |) Manager.USE_ALL_WIDTH)
    {
    public int getPreferredHeight() {}
    Return ((int) ((30 * screenHeight) / totalHeight));
    }

    public int getPreferredWidth() {}
    Return ((int) ((200 * screenWidth) / totalWidth));
    }

    protected void sublayout (int maxWidth, maxHeight int) {}
    Super.sublayout (getPreferredWidth (),
    getPreferredHeight());
    setExtent (getPreferredWidth (), getPreferredHeight());
    }
    };

    value = new CustomLabelField_Land ("" + ht.get ("currencySymbolLeft") +"", 12389754, 25, 0,)
    // 0);
    curencyPrice.add (value);

    String s = ht.get ('price') m:System.NET.SocketAddress.ToString ();

    Value1 = new CustomLabelField_Land (s, 1521508, 25, LabelField.FIELD_HCENTER, 0);

    curencyPrice.add (value1);
    value11 = new CustomLabelField_Land ("" + ht.get ("currencySymbolRight"), 12389754, 25, 0, 0);

    curencyPrice.add (value11);

    Thanks in advance

    By default, a LabelField will only the space he needs.  And a HFM will also take only the horizontal space he needs.  You can add your HFM to a VerticalFieldManager and ensure that the HFM says FIELD_HCENTER and it focuses, as a value for money defaults across the width.

  • 2 horizontalfield in a managhers

    I want to have 2 hoizontalfieldmanagers into one?

    the goal: I have a photo in the first horizontalfield Manager, while in the second I have list of scrollable tabs. If 2 horizontalfield managers... aims to keep the static image on the side... While on the rim just the second roll of horizontalfieldmanagers.

    Thanks for help

    its okey I solved first given it.i horizontal without scrol... second scrolling... my problem is that I gave first use all width... now I add them both in a horizontla and it works.

  • How to add the line of separation in the horizontal field Manager

    I want to get as

    name | Age | year

    all this in a horizontalfield Manager, how to do.

    I used the field separator, comes to the entire screen, such as

    name | Age | year

    |       |

    |       |

    |       |

    How do I solve this problem

    Thank you

    You can also do this by substituting your HorizontalFieldManager sublayout() method.

    As:

            h = new HorizontalFieldManager()
            {
                protected void sublayout( int maxWidth, int maxHeight )
                {
                    int width = Display.getWidth();
                    int height = 30; //height of the manager
    
                    super.sublayout( width, height);
                    setExtent( width, height);
                }
    
            };
    

    Concerning

    Bika

  • Is it possible a multiline EditField?

    I know that editfields automatically resize when text occupy several lines, but by default, they have a line height. I need an EditField with n lines by default (when it is empty).

    Now, I used a VerticalFieldManager substituted with a minimum height, where I put the (built with the USE_ALL_HEIGHT style bit) EditField, without success. The manager gets the minimum size, but the field keeps having a single line.

    This will help you.

    http://NA.BlackBerry.com/eng/devjournals/resources/journals/jul_2005/creating_textbox_field.jsp

  • How to add an auto incremented counter on an image?

    Hello

    I need to develop the screens as above...

    I just added 3 images bitmap in Horizontalfield Manager and the Manager has added to the screen, now, my problem is that I must add labelField on the image of the middle... .i can't do

    someone help me pls

    pls reply fast...

    "my problem is that I must add labelField on the Middle image.

    Can you explain what you mean by that.

    I see two possibilities:

    (1) you want to add it immediately above or below the Bitmap image - in which case the display will show

    Bitmap image

    Label
    bitmap image

    Bitmap image

    or

    Bitmap image

    Bitmap image

    Label

    Bitmap image

    This is easily done with a VerticalFieldManager by inserting the LabelField to the right place - see insert method.

    (2) However, I suspect that you want to have the label on top of the Bitmap image, i.e.

    Bitmap image

    Bitmap and label on top

    Bitmap image

    It's a little more complicated.  The best way to do this is to create a BitmapField that will display the text or alternatively, a LabelField that display a bitmap in the background.  These two are possible.

    Another alternative is to use a different layout manager and set the LabelField where the Bitmap image was placed.  I think it's possible, but I never did.

    My personal preference is to create a LabelField, who has a background Bitmap.  When the LabelField is not text, it acts as a BitmapField

    In any case, tell us which of these options, you are actually after and we'll see what we can do to help.

  • Newb question - displays only the first of several fields

    As a first application of Bb, I write a stopwatch and I want the larger time scale and the small milliseconds. As part of what I am trying to display several bitmap or label side-by-side fields, but when I run it using the Simulator, only the first is displayed.

    So, for example, what I want is:

    1-2: 3 4:5:6 7 8 9

    with each number in own field but what I mean is just

    1

    that is the first field. If I then use buttons they all appear in the verticalFieldManager by default in horizontalField Manager but if I use labels or bitmaps, then all I get is the first field, even if I remove the horizontalFieldManager and just use the default verticalFieldManager. I googled the question, this forum and spent several hours reading the code examples and documentation, but I have yet to understand why I can't put several fields of these types of side-by-side. I have to have something between them as separators or empty fields?

    The code that I've got so far is the following...

     public TimerView()    {     super();      HorizontalFieldManager timerField = new HorizontalFieldManager();
    
          Bitmap hour10 = Bitmap.getBitmapResource("num_1.png");        Bitmap hour01 = Bitmap.getBitmapResource("num_2.png");        Bitmap minute10 = Bitmap.getBitmapResource("num_3.png");      Bitmap minute01 = Bitmap.getBitmapResource("num_4.png");      Bitmap second10 = Bitmap.getBitmapResource("num_5.png");      Bitmap second01 = Bitmap.getBitmapResource("num_6.png");      Bitmap ms100 = Bitmap.getBitmapResource("num_7.png");     Bitmap ms010 = Bitmap.getBitmapResource("num_8.png");     Bitmap ms001 = Bitmap.getBitmapResource("num_9.png");     Bitmap colon = Bitmap.getBitmapResource("Colon.png");
    
          BitmapField bfHour10 = new BitmapField(hour10);       BitmapField bfHour01 = new BitmapField(hour01);       BitmapField bfHourColon = new BitmapField(colon);     BitmapField bfMinute10 = new BitmapField(minute10);       BitmapField bfMinute01 = new BitmapField(minute01);       BitmapField bfMinuteColon = new BitmapField(colon);       BitmapField bfSecond10 = new BitmapField(second10);       BitmapField bfSecond01 = new BitmapField(second01);       BitmapField bfSecondColon = new BitmapField(colon);       BitmapField bfMs100 = new BitmapField(ms100);     BitmapField bfMs010 = new BitmapField(ms010);     BitmapField bfMs001 = new BitmapField(ms001);
    
          timerField.add(bfHour10);     timerField.add(bfHour01);     timerField.add(bfHourColon);      timerField.add(bfMinute10);       timerField.add(bfMinute01);       timerField.add(bfMinuteColon);        timerField.add(bfSecond10);       timerField.add(bfSecond01);       timerField.add(bfSecondColon);        timerField.add(bfMs100);      timerField.add(bfMs010);      timerField.add(bfMs001);
    
            add(timerField);  }
    

    I know that this code violates probably some best practices or standards, but I intend to clean later.

    -edited for spelling

    Give it a go with images of the numbers.  You have it easy with BitmapFields, because you know how much space they need with

    getPreferredHeight() and getBitmapWidth().  Then you should be able to stick them next to each other.

    If I was doing this and who are looking for a special look at the clock, which seems to be what you are doing, I would like to have the digital icons as you do, and then set an image large enough to hold the value of the clock and in my routine of painting, select draw digital icon proper, in the right place.  As long as you load the bitmaps only once, I think it's the most effective way to do it.

    Of course, a much simpler way would be to have just a RichTextField formatted as you suggest - RichTextField because you can have two different fonts in a single field.

  • Label, change the field and the button on the problem of a line

    Hi all

    I was pulling my hair out on this and could really do with some tips. I'm putting a label, a text field and a button of bitmapfield on the same line, but for the life of me I can't work that way round. If I put the front button to the text box field, it works.

            // TEST 3 CONTROLS ON A ROW
    
            final Bitmap imgCalc = Bitmap.getBitmapResource("bgCalc.png");
    
            LabelField lb = new LabelField("0.00");
            EditField ef = new EditField();
            BitmapField  bf = new BitmapField(imgCalc, BitmapField.FOCUSABLE){
                protected void paint(Graphics g) {
                    // Draw text on button image
                    super.paint(g);
                    g.setColor(Color.WHITE);
                    int x = (40 - Font.getDefault().getAdvance("Go"))/2;
                    int y = (imgCalc.getHeight() - Font.getDefault().getHeight())/2;
                    g.drawText("Go", x, y);
                }
    
                public int getPreferredWidth(){
                    return 40;
                }
            };
    
            HorizontalFieldManager row0 = new HorizontalFieldManager();
    
            row0.add(lb);
            row0.add(ef);
            row0.add(bf);
    

    Excuse the code, but it's test code to make it work. As mentioned above, if I add that Label, Edit, Bitmap controls it only shows the label field and edit. If I swap the text field and the field bitmap around so that the text field is the last one, it works.

    What I am doing wrong?

    Thanks for looking

    Paul

    EditField always takes all of the width available to it.

    You must override its layout (width, height) and pass below the width values to leave space for the BitmapField. Something like

    protected void layout(int width, int height)
        {
            super.layout(width * 60 / 100, height);
            // sets width of this field to 60% of the total available width
        }
    

    would do.

  • CustomBitmapField

    Hi, friends, I implemented a CustomBitmapField but I need one highlights when I focus on it so that I implement:

    protected void drawFocus (Graphics g, boolean on) {}
    Paint (g);
    System.out .println ("drawFocus en is on?:" + I "");
    If (on) {}
    int prevAlpha = g.getGlobalAlpha ();
    int prevColor = g.getColor ();
    g.setGlobalAlpha (128);
    g.setColor (Color.ALICEBLUE);
    g.fillRect (0, 0, getWidth(), getHeight());
    g.setColor (prevColor);
    g.setGlobalAlpha (prevAlpha);
    }
    }

    but the way she's only highligth my when the land is on:

    1 I do not understand when is on

    2. I have this bitmapfields 5 in a Manager, but it is only trackball go right but when I go to the left is not isn't highligth

    can help me some body explain me about this

    Looks like my code I posted in this forum some time ago.

    Anyway - I'm not sure that I fully understand what you're asking, but:

    (1) in drawFocus is true if the field has the focus and false otherwise. So this code will give your image Bitmap a tinge of ALICEBLUE when it has focus and will normally paint what it doesn't. Is that what you see?

    (2) what exactly do you see when you roll the trackball to the left? No target field? If yes then I saw something similar on different BlackBerry simulators and phones every now and then - although in my case, the fields remained focused, but had a few graphical artifacts on the bottom. I guess that some of the code to update/unfocusing in older versions of BlackBerry OS is broken.

  • How to make a black background for a horizontalFieldManager?

    I have a custom HorizontalFieldManager that bears a label for the field. I want the background of the black horizontalField Manager. How can I do?

    Please help me...

    Unless you develop only for 4.6 + devices, setBackground won't help you (this set appeared in 4.6.0).

    The cleanest way will be

    protected void paintBackground(Graphics g) {
      int prevBgColor = g.getBackgroundColor();
      g.setBackgroundColor(Color.BLACK);
      g.clear();
      g.setBackgroundcolor(prevBgColor);
    }
    

    However, you also want to ensure that the text on your LabelField is visible, as prash_bb_dev pointed out.  Either have the LabelField use, say, white background (same solution in a different place, replace Color.BLACK with Color.WHITE ) or indeed set white color inside of object and call the super.paint ().

  • design Simulator problem

    I don't know if it's because of my code or the Simulator. I noticed that the Simulator (on my computer at least) sometimes messes up drawing. I got a ListField, who was shooting very well, but then I added a bitmap to the Manager (somewhere in the corner) and now the ListField mask some lines and trains them to new etc (changes occur when I scroll). also, I am writing a 5.0 app and the blackberry I have works on 4.7, so I can't really test. is this a known problem or is there something wrong with my code (which literally adds a ListField and a BitmapField to a Manager)?

    I solved the problem. rather than add a BitmapField and a ListField Manager Similarly, I added the BitmapField to a separate and then added Director as the Manager for the same manager as the ListField.

  • open and view an image

    Hello I need your help, I want to open and view an image located in the SDCard catre, how? Thank you

    to read the file, use

     public static synchronized byte[] readFile(String path) {
            byte[] data = null;
            try {
                FileConnection fconn = (FileConnection) Connector.open(path);
                // If no exception is thrown, then the URI is valid, but the file may or may not exist.
                if (!fconn.exists()) {
                    return null;
                }
    
                InputStream is = fconn.openInputStream();
                data = IOUtilities.streamToBytes(is);
                is.close();
    
                fconn.close();
            }
            catch (Throwable throwable) {
    
            }
    
            return data;
        }
    

    Then create EncodedImage using bytes of the image, set to EncodedImage BitmapField, BitmapField adds the display manager.

Maybe you are looking for

  • Impossible to connexiona Mozillazin

    I have the same user name and email address used to login to this account of support, but they will not be accepted for mozillazine, although they say both the user name and e-mail address are recognized?What's wrong?

  • 450G 0: 450 G 0 RAM update

    Dear, I'll update the RAM and want to make sure that memory, I chose is compatible with my laptop (HP 450G 0). Native memory set is Samsung SODIMM-12800 DDR3L 4 GB 16000 Mhz (M471B5173QH0-YK0). Memory, I would buy is Kingston SODIMM DDR3L-16000 8 Gb

  • Save the first for the 10.6.8 update at latest

    I want to save my BONES and music on a disc usb external hard. I asked a similar question, a month or two ago, but a few things have changed. Here are the details of what I want to accomplish and need advice please. 1. I have a drive external hard us

  • cannot reply to or forward e-mail, error number: 0x800CCC0E

    The connection to the server has failed. Subject ' Fw: Confirmation of the booking for Lynn Conner', account: 'CONNER BILLY', server: 'null', Protocol: SMTP, Port: 25, secure (SSL): no, Socket error: 10060, error number: 0x800CCC0E This happened for

  • Xperia calendar widget wastes space

    I love the Xperia (12.0.A.0.18) calendar and think that its user interface is superior to the Google Calendar application. However, I don't like the Xperia calendar widget. I like to have a nice and compact 2 x 2 calendar widget on my screen home - i