0

Like I want to customize it. I have been provided an image which I want to set it on my login button.

I tried Login.setBackground("loginbackground.png"); but it didn't go per my requirements. This question has duplicates but I didn't found a perfect solution that's why posting it :S

Thanks.

Ahmad Shahwaiz
  • 1,432
  • 1
  • 17
  • 35

1 Answers1

1

if you want to add image to button in background try it using below code :

Bitmap bitmap = Bitmap.getBitmapResource("rectangle.png");
Background background = BackgroundFactory.createBitmapBackground(bitmap);
button1 = new ButtonField("Button1", ButtonField.USE_ALL_WIDTH);
button1.setBackground(background);
add(button1);

or You can do it by adding image and adding click function to it in the below way :

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)
Aman Arora BB
  • 190
  • 1
  • 12