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.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.