黑莓可点击BitmapField [英] Blackberry Clickable BitmapField

查看:146
本文介绍了黑莓可点击BitmapField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建自定义BitmapField为把图标在我的菜单屏幕。我希望他们被点击。我也想给X和图标作为参数传递给自定义BitmapField的Y坐标。我该怎么做?


解决方案

 公共类CustomMenuButtonField扩展字段{
位图正常,重点突出;
公共CustomMenuButtonField(字符串bitmap1,字符串bitmap2){    正常= Bitmap.getBitma $ P $的PSource(bitmap1);
    专注= Bitmap.getBitma $ P $的PSource(bitmap2);}保护无效布局(INT宽度,高度INT){
    setExtent(宽度,高度); //根据你的设计他们设置
}保护布尔navigationClick(INT的地位,诠释时间)
{
    fieldChangeNotify(0);
    返回true;
}公共布尔isFocusable(){
    返回true;
}保护无效漆(图形图像){    如果(isFocus())
    {
        graphics.drawBitmap(0,0,宽度,高度,突出重点,0,0);
    }
    其他
    {
        graphics.drawBitmap(0,0,宽度,高度,正常,0,0);
    }}

}

如果你想给坐标参数,添加它们。高度和宽度是由你..

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 the Custom BitmapField. How can I do that?

解决方案

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

这篇关于黑莓可点击BitmapField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆