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

  • Home
  • SEARCH
  • 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 8260065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:00:19+00:00 2026-06-08T03:00:19+00:00

I have a screen which call a listfield . public class Main_AllLatestNews extends MainScreen

  • 0

I have a screen which call a listfield.

public class Main_AllLatestNews extends MainScreen {
private Database_Webservice webservice;
private String[] title, category, date, imagepath = {"no picture", "no picture", "no picture", "no picture","no picture","no picture","no picture","no picture","no picture", "no picture"};
private int[] newsid;
private List_News newslist;

public Main_AllLatestNews(final boolean needdownload) {
    super(USE_ALL_WIDTH);
    webservice = new Database_Webservice();
    add(new Custom_TopField(this, 0, -1, "", 1, 1));
    add(new Custom_BottomField(this, 0));
    add(new Custom_HeaderField(Config_GlobalFunction.latest));
    if (needdownload){
        Main.getUiApplication().pushScreen(
                new Custom_LoadingScreen(30));
        webservice.UpdateAllCatNews();          
    }else {
        webservice.LoadtodayNews(); 
        newsid = new int[webservice.news.size()];
        title = new String[webservice.news.size()];
        category = new String[webservice.news.size()];
        date = new String[webservice.news.size()];
        //imagepath = new String[webservice.news.size()];

        for (int i = 0; i < webservice.news.size(); i++) {
            newslist = (List_News) webservice.news.elementAt(i);
            newsid[i] = newslist.getID();
            title[i] = newslist.getNtitle();
            category[i] = newslist.getNewCatName();
            date[i] = newslist.getNArticalD();
            //imagepath[i] = newslist.getImagePath();
        }
        add(new Custom_ListField(newsid, title, date, category, imagepath, true));
    }
}
}

When I add custom_listfield then I get:

Failed to allocate timer 0: no slots left

Here is my listfield

public Custom_ListField(int newsid[], String title[], String date[],
        String category[], String imagepath[], boolean islatest) {
    super(0, ListField.MULTI_SELECT);
    this.newsid = newsid;
    setCallback(this);
    setBackground(Config_GlobalFunction.loadbackground("background.png"));
    this.islatest = islatest;
    rows = new Vector();

    for (int x = 0; x < title.length; x++) {
        TableRowManager row = new TableRowManager();

        titlelabel = new Custom_LabelField(title[x],
                LabelField.USE_ALL_WIDTH | DrawStyle.LEFT);
        titlelabel.setFont(Font.getDefault().derive(Font.BOLD, 23));
        row.add(titlelabel);

        datelabel = new Custom_LabelField(date[x], DrawStyle.ELLIPSIS
                | LabelField.USE_ALL_WIDTH | DrawStyle.LEFT);
        datelabel.setFont(Font.getDefault().derive(Font.BOLD, 18));
        datelabel.setFontColor(Color.GRAY);
        row.add(datelabel);

        categorylabel = new Custom_LabelField(category[x],
                DrawStyle.ELLIPSIS | LabelField.USE_ALL_WIDTH
                        | DrawStyle.LEFT);
        categorylabel.setFont(Font.getDefault().derive(Font.BOLD, 18));
        categorylabel.setFontColor(Color.RED);
        row.add(categorylabel);

        /*Bitmap imagebitmap = null;
        if (!imagepath[x].toString().equals("no picture")) {
            imagebitmap = Util_ImageLoader.loadImage(imagepath[x]);
        } else {
            imagepath[x] = "image_base.png";
            imagebitmap = Bitmap.getBitmapResource(imagepath[x]);
        }
        image = new BitmapField(imagebitmap, Field.FIELD_HCENTER
                | Field.FIELD_VCENTER);
        row.add(image);*/

        //setRowHeight(image.getBitmapHeight() + 10);
        setRowHeight(70);
        rows.addElement(row);
    }
    setSize(rows.size());
}

In this list, it will call 10 images or more. First I will check got link send to it else load local images. So the row height must be not same, however, it does not auto set row height for each row but set a same height to all row. I think out of memory because i call too many images? but I call in android also no problem.

This is my imageloader.

public class Util_ImageLoader {

public static Bitmap loadImage(String url) {
    HttpConnection connection = null;
    InputStream inputStream = null;
    EncodedImage bitmap;
    byte[] dataArray = null;

    try {
        // can use this for BlackBerry 5.0+ :
        // connection = (HttpConnection) (new
        // ConnectionFactory()).getConnection(url).getConnection();
        connection = (HttpConnection) Connector
                .open(url + Util_GetInternet.getConnParam(),
                        Connector.READ, true);
        int responseCode = connection.getResponseCode();
        if (responseCode == HttpConnection.HTTP_OK) {
            inputStream = connection.openDataInputStream();
            dataArray = IOUtilities.streamToBytes(inputStream);
        }
    } catch (Exception ex) {
    } finally {
        try {
            inputStream.close();
            connection.close();
        } catch (Exception e) {
        }
    }

    if (dataArray != null) {
        bitmap = EncodedImage.createEncodedImage(dataArray, 0,
                dataArray.length);
        return bitmap.getBitmap();
    } else {
        return null;
    }
}
}

1) What can I do to reduce the use of memory?

2) How to set different row height? I am set bitmap.getbitmapheight() but different bitmap will have different height.

//Updated//

I am running on simulator 9930 OS 7.0 and 8520 OS 5.0. Both also same result. Real Device cannot run because after signing the key also prompt the warning message try to Secure APi. I am completely commented all the images also same. I did not call neither online nor local image. I think is the data problem?

@AlanLai, can you tell us which device this is being run on, and which OS? Is it a simulator, or real hardware? Why don’t you try commenting out the image completely. Don’t show any images (network images, or local images). See if you still get the problem. Let’s try to narrow down where exactly the code is that’s causing your problem. Note: please post the information about which device you’re testing on above, in the question, not as a comment response here. Thanks

  • 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-08T03:00:24+00:00Added an answer on June 8, 2026 at 3:00 am

    The problem was the Custom_ListField. This should extends listfield
    instead of custom extends manager

    public class Custom_ListField extends ListField {
    private String[] title, category, date, imagepath;
    private int[] newsid, catsid;
    private List_News newslist;
    private Bitmap imagebitmap[], localimage = Bitmap
            .getBitmapResource("image_base.png");
    private BrowserField webpage;
    private Custom_BrowserFieldListener listener;
    private boolean islatest;
    
    private Vector content = null;
    private ListCallback callback = null;
    
    private int currentPosition = 0;
    
    public Custom_ListField(Vector content, boolean islatest) {
        this.content = content;
        this.islatest = islatest;
        newsid = new int[content.size()];
        title = new String[content.size()];
        category = new String[content.size()];
        date = new String[content.size()];
        imagepath = new String[content.size()];
        catsid = new int[content.size()];
        imagebitmap = new Bitmap[content.size()];
    
        for (int i = 0; i < content.size(); i++) {
            newslist = (List_News) content.elementAt(i);
            newsid[i] = newslist.getID();
            title[i] = newslist.getNtitle();
            category[i] = newslist.getNewCatName();
            date[i] = newslist.getNArticalD();
            imagepath[i] = newslist.getImagePath();
    
            if (!imagepath[i].toString().equals("no picture")) {
                imagebitmap[i] = Util_ImageLoader.loadImage(imagepath[i]);
            } else {
                imagebitmap[i] = localimage;
            }
            catsid[i] = newslist.getCatID();
        }
    
        initCallbackListening();
        this.setRowHeight(localimage.getHeight() + 10);
    }
    
    private void initCallbackListening() {
        callback = new ListCallback();
        this.setCallback(callback);
    }
    
    private class ListCallback implements ListFieldCallback {
    
        public ListCallback() {
            setBackground(Config_GlobalFunction
                    .loadbackground("background.png"));
        }
    
        public void drawListRow(ListField listField, Graphics graphics,
                int index, int y, int width) {
            currentPosition = index;
            graphics.drawBitmap(
                    Display.getWidth() - imagebitmap[index].getWidth() - 5,
                    y + 3, imagebitmap[index].getWidth(),
                    imagebitmap[index].getHeight(), imagebitmap[index], 0, 0);
            graphics.setColor(Color.WHITE);
            graphics.drawRect(0, y, width, imagebitmap[index].getHeight() + 10);
    
    
    
            graphics.setColor(Color.BLACK);
            graphics.setFont(Font.getDefault().derive(Font.BOLD, 20));
            graphics.drawText(title[index], 5, y + 3, 0, Display.getWidth()
                    - imagebitmap[index].getWidth() - 10);
    
            System.out.println(Display.getWidth()
                    - imagebitmap[index].getWidth() - 10);
    
            graphics.setColor(Color.GRAY);
            graphics.setFont(Font.getDefault().derive(Font.BOLD, 15));
            graphics.drawText(date[index], 5, y + 6
                    + Font.getDefault().getHeight() + 3);
    
            if (islatest) {
                graphics.setColor(Color.RED);
                graphics.setFont(Font.getDefault().derive(Font.BOLD, 15));
                graphics.drawText(category[index], Font.getDefault()
                        .getAdvance(date[index]) + 3, y + 6
                        + Font.getDefault().getHeight() + 3);
            }
        }
    
        public Object get(ListField listField, int index) {
            return content.elementAt(index);
        }
    
        public int getPreferredWidth(ListField listField) {
            return Display.getWidth();
        }
    
        public int indexOfList(ListField listField, String prefix, int start) {
            return content.indexOf(prefix, start);
        }
    }
    
    public int getCurrentPosition() {
        return currentPosition;
    }
    
    protected boolean navigationClick(int status, int time) {
        int index = getCurrentPosition();
        if (catsid[index] == 9) {
            if (Config_GlobalFunction.isConnected()) {
                webpage = new BrowserField();
                listener = new Custom_BrowserFieldListener();
                webpage.addListener(listener);
    
                MainScreen aboutus = new Menu_Aboutus();
                aboutus.add(webpage);
                Main.getUiApplication().pushScreen(aboutus);
    
                webpage.requestContent("http://www.orientaldaily.com.my/index.php?option=com_k2&view=item&id="
                        + newsid[index] + ":&Itemid=223");
            } else
                Config_GlobalFunction.Message(Config_GlobalFunction.nowifi, 1);
        } else
            Main.getUiApplication().pushScreen(
                    new Main_NewsDetail(newsid[index]));
        return true;
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 classes: class A have a declared protocol, which i call in
I have search screen which has 10 fields and involves around 5 to 6
I will have a screen in which there will be 11 images one below
Heres my issue. I have a login screen which is shown using PresentModalViewAnimated. Once
I have a GWT screen in which i have a file upload bar,whenever i
There are lots of java apps on my simulator menu screen which I have
I have searched for a while, to know which screen resolution i should consider
i have this GUI screen shots from the design team which i needs to
If I have a login screen and then the activity which displays the main
I have a full screen overlay for an About page, which sits over the

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.