0

我正在构建一个应用程序,我需要在 MapField 之上的 BitmapField。这个 BitmapField 需要是 Draggable ,即当我单击 BitmapField 并移动光标时,BitmapField 应该在不移动地图的情况下移动。可能吗??我怎样才能做到这一点..?

4

1 回答 1

0

试试这个代码:

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);
}
}
于 2012-01-20T09:21:39.543 回答