Question

I had created a HorizontalFieldManager & added BitmapFields in that.

In Blackberry Storm, Display.getWidth() is 480. In that I want to use first 450 to add some BitmapFields at LHS of screen which I m creating at runtime & add 2 BitmapFields at start at RHS of Screen.

2 BimapFields which I want to show at start r added in Constructor & other BitmapFields which I m creating at run time r added afterwords like..

class MyCanvas extends MainScreen
{

  MyCanvas()
  {

       hfm_BitmapField = new HorizontalFieldManager(){
             protected void sublayout(int maxWidth, int maxHeight) {
             super.sublayout(maxWidth, maxHeight);
             setExtent(Display.getWidth()-30, 60);
             }
         };


         startBitmap = Bitmap.getBitmapResource("start.png");
         startBitmapField = new BitmapField(startBitmap, BitmapField.ACTION_INVOKE |            BitmapField.FIELD_HCENTER | BitmapField.FIELD_RIGHT);
         hfm_BitmapField.add(startBitmapField);

         endBitmap = Bitmap.getBitmapResource("end.png");
         endBitmapField = new BitmapField(endBitmap, BitmapField.ACTION_INVOKE |            BitmapField.FIELD_HCENTER | BitmapField.FIELD_RIGHT);
         hfm_BitmapField.add(endBitmapField);

         drawBitmap();
 }


 public void drawBitmap()
 {
      bitmap[i] = new Bitmap(50, 50);
      Graphics g = new Graphics(bitmap[i]);
      g.drawLine(5,5,25,25);
      bitmapField[i] = new BitmapField(bitmap[i]);

      synchronized(UiApplication.getEventLock()) { hfm.add(bitmapField[i]); }
 }  

I want startBitmapField & endBitmapField at RHS & bitmapField[i] which I m creating at runtime at LHS of HorizontalFieldManagers.

I m thinking to add 2 HorizontalFieldManagers. 1 for bitmapField[i] & 1 for startBitmapField & endBitmapField. But how to add 2 HorizontalFieldManagers or any other FieldManagers in a row?

Any solution? How to do it?

Was it helpful?

Solution

You can put the 2 horizontal field managers inside another HorizontalFieldManager.

OTHER TIPS

Rather than use the alignment flags try adding to your sublayout method.

For each child of your Manager (hfm) you need to call setPositionChild. So if you want it right aligned and vertically centred you would do something like:

setPositionChild(deleteButton, hfm.getPreferredWidth() - deleteButton.getPreferredWidth(), (hfm.getPreferredHeight() / 2) - (deleteButton.getPreferredHeight() / 2));

This would set the top left hand corner of the delete button to be at the correct position such that it is right aligned and vertically centred within the hfm.

There is going to be a problem if you see the application in touch. You must have each of your customized field in a separate field manager to avoid using touch event. If you use layoutChild instead of super.sublayout(width,height), this will disable the navigation in the screen, so avoid using it. Use navigationMovement to customize your navigation of your fields. More: If you do not use super.sublayout function, it might not layout some of your fields, hence it is recommended that you use it.

More: use Storm emulator for all your touch based application, and 4.5 Pearl emulator JDEs for all the other releases, for the compatibility issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top