Blackberry Clickable BitmapField

前端 未结 1 1419
挽巷
挽巷 2020-12-22 06:28

I want to create a Custom BitmapField for putting Icons on my Menu Screen. I want them to be Clicked. I also want to give the X and Y coordinates of the icon as parameter to

1条回答
  •  生来不讨喜
    2020-12-22 06:43

    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..

    0 讨论(0)
提交回复
热议问题