Draggable BitmapField in blackberry

137 Views Asked by At

I am building an application where i need a BitmapField on top of the MapField. This BitmapField need to be Draggable i.e. when I click on the BitmapField and move the cursor, BitmapField should move without moving the map. Is it possible?? How can i do this..?

1

There are 1 best solutions below

6
On

Try this code:

public class Def extends MainScreen
{
VerticalFieldManager vertical;
BitmapField bitmapField;
int px=0,py=0;
public Def() 
{
    vertical=new VerticalFieldManager()
    {
        protected void sublayout(int maxWidth, int maxHeight) 
        {
            super.sublayout(Display.getWidth(),Display.getHeight());
            setExtent(Display.getWidth(),Display.getHeight());
        }       
    };
    vertical.setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("background.png")));//put here map image;

    bitmapField=new BitmapField(Bitmap.getBitmapResource("rectanagle.png"));//For moving give small image;
    vertical.add(bitmapField);
    add(vertical);

}

protected boolean navigationMovement(int dx, int dy, int status, int time) 
{
    px=px+dx;
    py=py+dy;
    XYEdges xyEdges=new XYEdges(py, 0, 0, px);
    bitmapField.setPadding(xyEdges);
    vertical.invalidate();
    return super.navigationMovement(dx, dy, status, time);
}
}