2012-01-20 71 views
0

我正在構建一個應用程序,我需要在MapField上使用BitmapField。這個BitmapField需要是可拖動的,即當我點擊BitmapField並移動光標時,BitmapField應該移動而不移動地圖。可能嗎??我怎樣才能做到這一點..?黑莓中的可拖動位圖字段

回答

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); 
} 
} 
+0

嘿感謝... BT如何把地圖作爲圖像? – Swati

+0

我已經對代碼放置了地圖圖像的評論;看代碼一次;有任何疑問來下面的聊天室:http://stackoverflow.com/questions/8937674/draggable-bitmapfield-in-blackberry/8939113#8939113 在這裏somany是有解決方案 – alishaik786

+0

我想問..如何得到這張地圖作爲圖像.. ?? – Swati