Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd
Accepted Solution

Change bitmap background image on click

i have label with some text on label..., and i have add a image with bitmap just below the label.i have put navigation click on that image.for click event. now what i want,
first- when i click on that image the image will be changed to another image(second bitmap) 
and
second- my text will be saved to my Database,i have done the second. 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change bitmap background image on click

Use the setBitmap(<new bitmap>) method for your BitmapField while processing the click.  This will change it for you.  I would make sure the images are the same size.

 

You mention background in your description so I am not sure that this is the answer you want.  If it is not, can you describe how you set the image you want to change originally?

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: Change bitmap background image on click

i just want to change the image onclick ...
when i click to my image that will be changed to another image and the size are same

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change bitmap background image on click

In the method that detects the click, just use setBitmap(<new image>).

 

Does that not work for you?

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: Change bitmap background image on click

i will try....
Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: Change bitmap background image on click

that did not work for me.. can u provide some code to me
Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: Change bitmap background image on click

[ Edited ]

here is my code
public final class MyScreen extends MainScreen
{

MyScreen()
{
setTitle("image");
Bitmap bitmapImage = Bitmap.getBitmapResource("mfocus.png");
BitmapField fieldDemo = new BitmapField(bitmapImage,BitmapField.FOCUSABLE){
protected boolean navigationClick(int status, int time)
{
Graphics g = null ;
g.drawBitmap();// here i will put mt second bitmap

return true;
}


};



add(fieldDemo);
}


}

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change bitmap background image on click

I re commend that you review the documentation for BitmapField.

 

Replace this:

 

protected boolean navigationClick(int status, int time)
{
Graphics g = null ;
g.drawBitmap();// here i will put mt second bitmap
.....

 

with this:

protected boolean navigationClick(int status, int time)
{
this.setBitmap(<new Bitmap>);
.....

Please use plain text.
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: Change bitmap background image on click

yes that will work for the second bitmap has been drawn when i click the first bitmap.
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change bitmap background image on click

Problem solved then?

 

If so, please mark this Thread as Solved - see instructions in the Help Lnk near the top if you are not sure about this. 

Please use plain text.