Blackberry Clickable BitmapField

只愿长相守 提交于 2019-11-29 17:51:40
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);
    }

}

}

If you want to give coordinates as parameters , add them. Height and width is up to you..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!