2011-04-19 8 views
0

メニュー画面にアイコンを配置するためのカスタムBitmapFieldを作成します。私はそれらをクリックしてもらいたい。また、アイコンのX座標とY座標をパラメータとしてカスタムBitmapFieldに渡したいと思っています。どうやってやるの?Blackberry Clickable BitmapField

答えて

0
public class CustomMenuButtonField extends Field{ 
Bitmap normal,focused; 
public CustomMenuButtonField(String bitmap1, String bitmap2) { 

    normal = Bitmap.getBitmapResource(bitmap1); 
    focused = Bitmap.getBitmapResource(bitmap2); 

} 

protected void layout(int width, int height) { 
    setExtent(width, height); // Set them according to your design 
} 

protected boolean navigationClick(int status, int time) 
{ 
    fieldChangeNotify(0); 
    return true; 
} 

public boolean isFocusable() { 
    return true; 
} 

protected void paint(Graphics graphics) { 

    if(isFocus()) 
    { 
     graphics.drawBitmap(0, 0, width, height, focused, 0, 0); 
    } 
    else 
    { 
     graphics.drawBitmap(0, 0, width, height, normal, 0, 0); 
    } 

} 

}

あなたは、パラメータとして、座標を与えたい場合は、それらを追加します。高さと幅はあなた次第です..

関連する問題