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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Trusted Contributor
Posts: 146
Registered: ‎03-22-2010
My Device: Not Specified

Re: How to update display

you can store selected choice in objectchoicefield as string as  follows:

 

String sex=sexChoices[sexChoiceField.getSelectedIndex()];

 

also i would suggest you write this inside field change so you get updates choice and invalidate only bitmap as follows,

 

//    ObjectChoiceField
 String[] sexChoices = {"Male", "Female"};
 ObjectChoiceField sexChoiceField = new ObjectChoiceField("Sex: ", sexChoices);


  public void fieldChanged(Field field, int context){

String sex=sexChoices[sexChoiceField.getSelectedIndex()];

  if (field == saveProfileBtn){
   Profile2 profile2 = new Profile2();
   UiApplication.getUiApplication().pushScreen(profile2);
  }
  if(field == sexChoiceField && sex..equalsIgnoreCase("Female")){
   
   titleMan.invalidate();
   profilePicField.setBitmap(bitmapFemale);
   profilePicField.invalidate();
  }
 }

 

try and let us know if you solved your problem

Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10
My Carrier: Telus

Re: How to update display

I'm getting 

 

The method invalidate() from the type Field is not visible

 

for profilePicField.invalidate();

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to update display

Ah how annoying is that.  invalidate() is protected for the BitmapField....

 

Sorry hadn't realized that.

 

Ok, quickest thing to do is this.  Change:

 

  titleMan.invalidate();
   profilePicField.setBitmap(bitmapFemale);

 

in the code you posted a while ago to this:


   profilePicField.setBitmap(bitmapFemale);

  titleMan.invalidate();

 

So do the invalidate after you have changed the Bitmap.

 

If this works OK, then we can look at extending BitmapField to allow invalidate().

Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10
My Carrier: Telus

Re: How to update display

No dice. The complete class can be seen here. Thanks again for al the help.

 

http://pastebin.com/JdFKbPq5

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to update display

Sorry not looked at your code.

 

Just knocked up the following, seems to do what you want.  I suggest you try it, make sure it works, then compare it with that you have to see if you can see a problem.

 

class MyMainScreen extends MainScreen
                   implements FieldChangeListener {
    Bitmap _bitmapQ = Bitmap.getPredefinedBitmap(Bitmap.QUESTION);
    Bitmap _bitmapE = Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION);
    public static String [] CHOICES = new String [] { "Q", "E" };
    ObjectChoiceField _chooseOne = new ObjectChoiceField("Choose One: ", CHOICES);
    BitmapField _chosenIcon = new BitmapField(_bitmapQ);
    public MyMainScreen() {
        super();
        this.add(_chooseOne);
        _chooseOne.setChangeListener(this);
        this.add(_chosenIcon);
    }
    public void fieldChanged(Field f, int context) {
        if ( f == _chooseOne ) {
            String choice = CHOICES[_chooseOne.getSelectedIndex()];
            if ( choice.equals("Q") ) {
                _chosenIcon.setBitmap(_bitmapQ);
            } else {
                _chosenIcon.setBitmap(_bitmapE);
            }
            this.invalidate();
        }
    }
}

 

Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10
My Carrier: Telus

Re: How to update display

Thank you very much everyone. In the end I was able to correct my code using peter's example. I'm really embarased to say that I setChangeListener to the bitmapfield instead of the objectchoicefield. Again thanks everyone, peter once again you came to the rescue.