Creating advanced user interfaces blackberry

2019-08-14 05:04发布

I am looking out to create a text box similar to the image shown below in my blackberry form. As of now i am able to add a textfield which has a label like say

              Name:(Cursor blinks)

Also when i try adding an image it doesnt show up beside the label but below it.I have tried aligning and adjusting image size etc but all in vain.How can layout managers help me do this any idea?

Can some one provide me an exact way as to how this can be achieved.Thanks in advance.

enter image description here

     //Lets say adding  textfield with validation for name
     TextField1 = new TextField("\n Customer Name: ",null)
     {
            protected boolean keyChar(char ch, int status, int time) 
            {
            if (CharacterUtilities.isLetter(ch) || (ch == Characters.BACKSPACE || (ch == Characters.SPACE))) 
            {
            return super.keyChar(ch, status, time);
            }
           return true;
            }
        };
       add(TextField1);

      //Or either by using this,the text is placed within the image
    Border myBorder = BorderFactory.createBitmapBorder( 
    new XYEdges(20, 16, 27, 23),
    Bitmap.getBitmapResource("border.png"));
    TextField myField = new TextField(" Write something ",TextField.USE_ALL_WIDTH | TextField.FIELD_HCENTER)
    {
      protected void paint(Graphics g) {
        g.setColor(Color.BLUE);
        super.paint(g);
    }
    };  

   myField.setBorder(myBorder);
   add(myField);

//After trying out code given at Blackberry App Appearance VS Facebook App i am getting the following layout

enter image description here

I would still want to achieve a box that stands beside the label.Like the one shown in green image.Please guide.

1条回答
戒情不戒烟
2楼-- · 2019-08-14 05:23

Have a look to this answer. I think it may be helpful to you. Just play with the code until you get your desired look and feel.

查看更多
登录 后发表回答