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 6991169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:27:36+00:00 2026-05-27T19:27:36+00:00

Here is the paint method of my custom field: protected void paint(Graphics graphics) {

  • 0

Here is the paint method of my custom field:

   protected void paint(Graphics graphics) {

            new downloadImage();
            Bitmap img =  downloadImage.connectServerForImage(this.poster);


            graphics.drawBitmap(0, 0, 100, 150, img, LEFT, TOP);
     }

Here is the connectServerForImage method:

public static Bitmap connectServerForImage(String url) {

          HttpConnection httpConnection = null;
          DataOutputStream httpDataOutput = null;
          InputStream httpInput = null;
          int rc;

          Bitmap bitmp = null;
          try {
           httpConnection = (HttpConnection) Connector.open(url);
           rc = httpConnection.getResponseCode();
           if (rc != HttpConnection.HTTP_OK) {
            throw new IOException("HTTP response code: " + rc);
           }
           httpInput = httpConnection.openInputStream();
           InputStream inp = httpInput;
           byte[] b = IOUtilities.streamToBytes(inp);
           EncodedImage hai = EncodedImage.createEncodedImage(b, 0, b.length);
           return hai.getBitmap();

          } catch (Exception ex) {
           System.out.println("URL Bitmap Error........" + ex.getMessage());
          } finally {
           try {
            if (httpInput != null)
             httpInput.close();
            if (httpDataOutput != null)
             httpDataOutput.close();
            if (httpConnection != null)
             httpConnection.close();
           } catch (Exception e) {
            e.printStackTrace();

           }
          }
          return bitmp;
         }

I’m putting multiple instances of my custom field into a verticalfieldmanager, but the images slows the scrolling down. It seems as if every time I scroll it runs the paint method again even though the image has already been downloaded.

I’m thinking I will need to download the images in another thread? Someone lead me in the right direction.

  • 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-27T19:27:37+00:00Added an answer on May 27, 2026 at 7:27 pm
    1. You must start any HTTP interaction in a separate thread (no blocking call).
    2. To avoid downloading same image multiple times cache already downloaded image. You can use image download URL as image tag to store
      them.
    3. Every time there is a event on screen, paint method will be called. So don’t start download an image if it is already downloaded.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I ensure that my custom field's *to_python()* method is only called when
How can I ensure that my custom field's *to_python()* method is only called when
I'm drawing a Bitmap as a background for a custom field but it doesn't
I'm staring blank on this error, so I hope someone here can point out
Here's what I got so far (that doesn't work). At this point I thought
So what I'm looking for here is something like PHP's print_r function. This is
I am a N00b here . I print my currency like this : -(IBAction)buttonPressed1:(id)sender
I'm writing a Blackberry app. I have a custom list field where I can
I have this problem bothering me for days. I'm making a special paint program.
In Contacts I have set up a Date field with a custom label (when

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.