Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Button 黑莓-将图像添加到按钮?_Button_Blackberry_Blackberry Jde - Fatal编程技术网

Button 黑莓-将图像添加到按钮?

Button 黑莓-将图像添加到按钮?,button,blackberry,blackberry-jde,Button,Blackberry,Blackberry Jde,就像我想定制一样。我已经提供了一个图像,我想设置在我的登录按钮 我尝试了Login.setBackground(“loginbackground.png”);但它不符合我的要求。这个问题有重复,但我没有找到一个完美的解决方案,这就是为什么张贴它:s 谢谢。如果您想将图像添加到背景中的按钮,请使用以下代码进行尝试: Bitmap bitmap = Bitmap.getBitmapResource("rectangle.png"); Background background = Backgroun

就像我想定制一样。我已经提供了一个图像,我想设置在我的登录按钮


我尝试了Login.setBackground(“loginbackground.png”);但它不符合我的要求。这个问题有重复,但我没有找到一个完美的解决方案,这就是为什么张贴它:s


谢谢。

如果您想将图像添加到背景中的按钮,请使用以下代码进行尝试:

Bitmap bitmap = Bitmap.getBitmapResource("rectangle.png");
Background background = BackgroundFactory.createBitmapBackground(bitmap);
button1 = new ButtonField("Button1", ButtonField.USE_ALL_WIDTH);
button1.setBackground(background);
add(button1);
或者,您可以通过以下方式添加图像并向其添加单击功能:

Bitmap msg = Bitmap.getBitmapResource("msg.png");
BitmapField message = new BitmapField(msg, Field.FOCUSABLE)
{
    protected boolean navigationClick(int status,int time)
    {
        label.setText("Messages");
        Dialog.alert("Message icon selected");
        return true;
    }
};
add(message)

您可以使用图像按钮代替普通按钮。因此,无需为按钮设置背景“此问题有重复项,但我没有找到完美的解决方案”问完全相同的问题时,您为什么希望得到不同的答案?例如: