黑莓 - 如何与占据图像的完整按钮 [英] BlackBerry - how to occupy a complete button with image

查看:84
本文介绍了黑莓 - 如何与占据图像的完整按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了黑莓code将图像添加到ButtonField字段。我希望整个按钮由图像所占据,但图像上未ButtonField字段完全显示。
有很多在上边距,左,右的按钮。我试图使用的cellpadding,但没有奏效。

I have written BlackBerry code to add an image to a ButtonField. I want the whole button to be occupied by the image, but the image is not displayed completely on the ButtonField. There is a lot of margin on the top, left and right of the button. I tried to use cellpadding but it didn't work.

我怎样才能减少ButtonField字段的宽度和高度,所以它的41点¯x41原始图像尺寸相匹配?

How can I reduce the width and height of the ButtonField so it matches the original image size of 41 x 41?

推荐答案

而不是增加一个图像按钮扩展图像类,并把它转换成一个按钮,通过覆盖isFocusable(),navigationClick(),trackwheelClick()和keyChar()。这里的code:

Instead of adding an image to a button extend the image class and turn that into a button by overriding isFocusable(), navigationClick(), trackwheelClick(), and keyChar(). Here's the code:

public class ImageButtonField extends BitmapField
{
    public ImageButtonField(Bitmap image) {
        super(image);
    }

    public boolean isFocusable() {
        return true;
    }

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

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

    protected boolean keyChar(char character, int status, int time) {
        if(Characters.ENTER == character || Characters.SPACE == character) {
            fieldChangeNotify(0);
            return true;
        }
        return super.keyChar(character, status, time);
    }
}

这篇关于黑莓 - 如何与占据图像的完整按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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