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
Regular Contributor
Posts: 63
Registered: ‎08-30-2012
My Device: 9900
My Carrier: Various

Blackberry Custom Image button

i have created a custom image button,one is play image button and one is pause image button,i want to switch between play and pause(i.e when the user clicks on the button,it has to change(play to pause or pause to play),for my requirement i have referred this example url when i execute my program ,i am able to display the button,but when i click on the button,i am not able to change the imagebutton(play to pause),can any one help me?

Developer
Posts: 246
Registered: ‎09-30-2010
My Device: Z10, Onyx2
My Carrier: IND XL

Re: Blackberry Custom Image button

you need to crate a state for play and pause.
from the example it only for focus

maybe on navigationClick you could do a change image
if(play) _currentpicture = pausepicture;
else _currentpicture = playpicture;

Developer
Posts: 1,540
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Blackberry Custom Image button

you need to manually set the button to the "toggle" image in your code when the button is pressed.

If you use BitmapField then you can use this method to change it

 

void

setBitmap(Bitmap bitmap)

Regular Contributor
Posts: 63
Registered: ‎08-30-2012
My Device: 9900
My Carrier: Various

Re: Blackberry Custom Image button

[ Edited ]

how to identify my click event in navigation method,i roughly written like this ,can you chec this once

 

boolean result=fasle;

protected boolean navigationClick(int status, int time){

if(result){
_currentPicture=_offPicture;
}
else{
_currentPicture=_onPicture;
}
return true;
}

Developer
Posts: 246
Registered: ‎09-30-2010
My Device: Z10, Onyx2
My Carrier: IND XL

Re: Blackberry Custom Image button

[ Edited ]


when creating button the button is not playing so it was false;
boolean play = false;

protected boolean navigationClick(int status, int time){
// when user click this will create a notification
play = play ? false : true;
if(play){
_currentPicture=_offPicture;
}
else{
_currentPicture=_onPicture;
}

fieldChangeNotify(1);
return true;
}

Developer
Posts: 673
Registered: ‎08-09-2010
My Device: Not Specified

Re: Blackberry Custom Image button

Hello,

 

    Please follow below step.

 

    1.Take one boolean variable 

    2.When user click into Playbutton at that time this variable assign true.

    3. And when user click into PushButton at that time variable value assign false.

 

  

    

 Note :- As per code i take one manager innerplayerControlManager.

 

if (_isPlaying) {
			pushButton = new CustomBitmapField(pushFocus, pushNormal,
					FIELD_HCENTER);
			pushButton.setChangeListener(this);
			innerplayerControlManager.add(pushButton);
		} else {
			playButton = new CustomBitmapField(playFocus, playNormal,
					FIELD_HCENTER);
			playButton.setChangeListener(this);
			innerplayerControlManager.add(playButton);
		}

Click Event	

if (field instanceof CustomBitmapField) { if (context == 0) { if (field.equals(playButton)) { try { _isPlaying = true; innerplayerControlManager.deleteAll(); } catch (Exception e) { // TODO: handle exception } } else if (field.equals(pushButton)) { _isPlaying = false; innerplayerControlManager.deleteAll(); }

 

Thanks.

 

-----------------------------------------------------------------------------------------------------------------------------------------

feel free to press the like button on the right side to thank the user that helped you.

Developer
Posts: 673
Registered: ‎08-09-2010
My Device: Not Specified

Re: Blackberry Custom Image button

If you got success and solved this issue then click into Accept Button.

Regular Contributor
Posts: 63
Registered: ‎08-30-2012
My Device: 9900
My Carrier: Various

Re: Blackberry Custom Image button

i haven't  try your answer,if it solves ,sure ,i will accept ,what is this reference innerplayerControlManager