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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:13:24+00:00 2026-06-16T03:13:24+00:00

I am new to BlackBerry development. But good about android. I want to load

  • 0

I am new to BlackBerry development. But good about android.

I want to load Images coming from the server in ListField.

I have implement like below code but not getting success:

   package mypackage;


public class TempScreen extends MainScreen implements ListFieldCallback{
    Bitmap[] images=null;
    private ListField mylist;
    private static Bitmap _bitmap;
    private ImageDownloader downloader;
    int size = 0;
    String[] urls={
            "http://www.kentnews.co.uk/polopoly_fs/damian_lewis_at_port_lympne_wild_animal_park_c_taf_1_1738362!image/2626063106.jpg_gen/derivatives/landscape_225/2626063106.jpg",
            "http://www.kentnews.co.uk/polopoly_fs/damian_lewis_at_port_lympne_wild_animal_park_c_taf_1_1738362!image/2626063106.jpg_gen/derivatives/landscape_225/2626063106.jpg",
            "http://www.kentnews.co.uk/polopoly_fs/damian_lewis_at_port_lympne_wild_animal_park_c_taf_1_1738362!image/2626063106.jpg_gen/derivatives/landscape_225/2626063106.jpg",
            "http://www.kentnews.co.uk/polopoly_fs/damian_lewis_at_port_lympne_wild_animal_park_c_taf_1_1738362!image/2626063106.jpg_gen/derivatives/landscape_225/2626063106.jpg"};
    public TempScreen()
    {


        images=new Bitmap[urls.length];
        size = urls.length;
        mylist = new ListField();
        mylist.setCallback(this);
        mylist.setSize(4);
        mylist.setRowHeight(getFont().getHeight() * 3);
        add(mylist);
        Thread downloader=new Thread(new ImageDownloader());
        downloader.start();

    }


    public void drawListRow(ListField listField, Graphics graphics, int index,
            int y, int width) {

        if(images[index]==null)
         {
             //Load placeholder image
            _bitmap = Bitmap.getBitmapResource("close_btn.png");// load some bitmap
            // of your choice
            // here
         }
         else
             //Load Bitmap
            _bitmap = images[index]; 

        graphics.drawText("row details", 100, y + 30);
        //graphics.drawBitmap(0, y, _bitmap.getWidth(), _bitmap.getHeight(),_bitmap, 0, 0);
        mylist.invalidate(index);
    }

    public class ImageDownloader implements Runnable
    {
        public void run()
        { 
            for(int i=0; i<size;i++)
            { 
                 if(images[i]==null) 
                 { 
                      images[i]=connectServerForImage(urls[i].toString());//replace downloadImage method to whatever method       you have to download the bitmap from url 
                      UiApplication.getUiApplication().invokeLater(new Runnable(){
                          public void run()
                          {
                              mylist.invalidate();
                          }
                      });
                  }
             }
        }
    }
    public Object get(ListField listField, int index) {
        // TODO Auto-generated method stub
        return null;
    }
    public int getPreferredWidth(ListField listField) {
        // TODO Auto-generated method stub
        return 0;
    }
    public int indexOfList(ListField listField, String prefix, int start) {
        // TODO Auto-generated method stub
        return 0;
    }
    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+";interface=wifi");
            httpConnection = (HttpConnection) Connector.open(url);
            rc = httpConnection.getResponseCode();
            // System.out.println("===============================");
            Dialog.alert("beore if condition");
            if (rc == HttpConnection.HTTP_OK) {

                System.out.println(" ============= IN FUNCTION. . . . .");
                httpInput = httpConnection.openInputStream();
                InputStream inp = httpInput;
                byte[] b = IOUtilities.streamToBytes(inp);
                EncodedImage hai = EncodedImage.createEncodedImage(b, 0,
                        b.length);
                bitmp = hai.getBitmap();
            } else {
                throw new IOException("HTTP response code: " + rc);
            }
        } 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;
    }
}

Dont know where i am wrong. Please can any budy help me for the same.

  • 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-06-16T03:13:25+00:00Added an answer on June 16, 2026 at 3:13 am

    You can try using this link :
    http://www.coderholic.com/blackberry-webbitmapfield/

    You have to create a separate class named as WebBitmapField as suggested in above link.

    How to use that class in your list field image objects:

    • For every image url create WebBitmapField object
    • photoList_vector is the vector through which populate elements in
      list field

      WebBitmapField web = new WebBitmapField("http://www.image1.png"); 
      
      photoList_vector.addElement(web);
      
      web = new WebBitmapField("http://www.image2.png"); 
      
      photoList_vector.addElement(web);
      

    Now use this vector to work on your list field……

    In the above lines we try to ensure that when we simultaneously send multiple requests to get the images then each image corresponds to a particular WebBitmapField Object.

    Each object is then added to vector so that it can be added to the list field.

    Each url send is tied to an object of WebBitmapField.

    So though request is send in a separate thread it gets tied to its associated object only

    Hope it helps
    🙂

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

Sidebar

Related Questions

I am new to BlackBerry Development (5.0). I have a little experience in Android
I'm new to Blackberry development and have come across something I don't understand. I
I'm completely new to BlackBerry development, but I'm experienced in Java ME development. While
I'm new to Blackberry Development and i have to implement a search functionality. It
I am new to blackberry development. I want to add a check-box or tick
i am new in blackberry development world. and i have task to develop the
I'm new to Blackberry development. Currently, i have an instance of TableLayoutManager to add
i am new to blackberry development. i want to know is there any other
I'm new to Android, but have published iphone and bberry apps. I see that
I'm new in blackberry development and I want to know if there is some

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.