Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7495023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:55:24+00:00 2026-05-29T17:55:24+00:00

I may seem ignorant but I have not found much information about how to

  • 0

I may seem ignorant but I have not found much information about how to go about my problem developing my BlackBerry application.

Basically I have constructed a UI that contains a few image buttons. What I want to do is when I click on one of the buttons, I want an image at the center of the screen to switch seemlessly to another image.

I am currently not using any threads though from what I’ve gathered I need to?

Or do I simply have to push a new screen in my button listener and recall the class’s constructor and rebuild the page with different images?

Sorry if this is unclear, I would really appreciate some basic info on how to do this or a link that explains page refreshing in detail for blackberry!

Thanks alot

EDIT : Okay here is a very small part of my code :

This is basically the last thing I have tried in the listeners, I dont know how to change the image (flagField) when I press one of the two buttons! The only thing that worked for me was pushScreen(new Csps(“americanflag”)); every time I would press on a button, but the performance was bad and I was left with a stack of screens, not ideal.

I have been trying to do this all day long hehe… sigh , here goes:

public class CSP extends UiApplication 
{
public static void main(String[] args)
{
    CSP theApp = new CSP(); 
    theApp.enterEventDispatcher(); 
}

public CSP() 
{ 
    CSPS csps = new CSPS();
    pushScreen(csps); 
} 
}

class CSPS extends MainScreen implements FieldChangeListener
{

int width = Display.getWidth();
int height = Display.getHeight();

ButtonField backButton;

ImageButtonField canadianFlag;
ImageButtonField americanFlag;
Bitmap changeableFlag;
String currentFlag ="canada_flag.png";
BitmapField flagField;

canadianFlag = construct("canada_flag.png", 0.18);
americanFlag = construct("us.gif", 0.18);

    canadianFlag.setChangeListener(this);
    americanFlag.setChangeListener(this);

    add(flagField);
    add(canadianFlag);
    add(americanFlag);
//LISTENERS
public void fieldChanged(Field field, int context){


    if(field == canadianFlag){
        setCurrentFlagResource("canada_flag.png");
        BitmapField newFlagField = populateFlagField(currentFlag, 0.3);
        replace(flagField, newFlagField);

        this.invalidate();
        this.doPaint();
        this.updateDisplay();

    }
    else if(field == americanFlag){

        setCurrentFlagResource("american-flag.gif");
        BitmapField newFlagField = populateFlagField(currentFlag, 0.3);
        replace(flagField, newFlagField);

        this.invalidate();
        this.doPaint();
        this.updateDisplay();

    }

the setCurrentFlagRessource method sets the flagField attribute to the appropriate BitmapField

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:55:27+00:00Added an answer on May 29, 2026 at 5:55 pm

    There is a method called setBitmap() in the BitmapField.

    In the listeners you should simply call flagField.setBitmap(newbitmap). You can also use the method setImage(). There is no need to call invalidate(), updateUI etc.

    If you get any IllegalStateException while using this method, simply get a lock on the Applicaton Event lock object or invokeLater() this code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem like an obvious problem, but I have looked on the facebook
This may seem weird but I have a problem in one of my programs
this may seem like a simple problem but I couldn't find it in the
This may seem simple, but somehow it isn't. I have a table of historical
This may seem like a simple problem to solve, but I'm new to Android
This may seem like a dumb question but I have IDLE and I'm trying
This may seem silly but I seem to have forgotten the order of replacement
It may seem to be asked several times, but I could not find answers
This may seem like a silly question but it's something I've never found an
This may seem like a dumb question, or even subjective, but I'm not sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.