How to change the picture of CustomButtonField on click event?

Posted by Ujjal boruah Vinod on Stack Overflow See other posts from Stack Overflow or by Ujjal boruah Vinod
Published on 2011-06-29T10:53:18Z Indexed on 2011/06/29 16:22 UTC
Read the original article Hit count: 166

Filed under:
|

I have posted this question previously but the answer is not appropiate. The solution provided just change the picture when the custombutton has focus and unfocus. Suppose in my application I need to change the picture if the user clicks on the customButton, n i m doing this by calling the same screen (ie UiApplication.getUiApplication().pushScreen(new Screen2(b));) . Screen2 is the screen which holds the customButton. On the click evevt i m pushing the same screen by passing aint variable pic_status that determines which picture to be drawn in the CustomButton in the new screen. Is there any way to update the picture in the CustomButtonField on click event without pushing the same Screen again and again.

 //code in Screen2

public void fieldChanged(Field field, int context) 
 {
    if(field == bf1)
     {

         if(pic_status == 0)
         {
             pic_status=1;


         }
       UiApplication.getUiApplication().pushScreen(new Screen2(pic_status));    


  }



 //code in CustomButtonField

CustomButtonField(String label,int pic_status,long style) 
{    
    super(style);
    this.label = label;
    this.labelHeight = getFont().getHeight();
    this.labelWidth = getFont().getAdvance(label);
    this.notice = s;
    if(pic_status ==0)
    {
    currentPicture1 = onPicture;
    currentPicture2 = onPicture;
    }
    if(pic_status ==1)
    {
    currentPicture1 = clickPicture;
    currentPicture2 = onPicture;
    }
    if( pic_status==2 )
    {
        currentPicture1 = onPicture;
        currentPicture2 = clickPicture;
    }
}

I need a way to update the customButtonField text and picture on the buttonClick event not on focus/unfocus event without pushing the same Screen again and again. If my above description of problem is not satisfactory, plz add a comment n i can give more details explanation of my problem?

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about java-me