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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:37:23+00:00 2026-06-08T12:37:23+00:00

This is my latest Custom_Listfield class. public class Custom_ListField extends ListField { private String[]

  • 0

This is my latest Custom_Listfield class.

public class Custom_ListField extends ListField {
private String[] title, category, date, imagepath;
private int[] newsid, catsid;
private List_News newslist;
private Bitmap imagebitmap[], localimage = Config_GlobalFunction
        .Bitmap("image_base.png");
private BrowserField webpage;
private boolean islatest;
private int highest = 0;

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();
        catsid[i] = newslist.getCatID();

        if (!imagepath[i].toString().equals("no picture")) {
            imagebitmap[i] = Util_ImageLoader.loadImage(imagepath[i]);
            if (imagebitmap[i].getHeight() > highest)
                highest = imagebitmap[i].getHeight();
        } else {
            imagebitmap[i] = localimage;
        }
        catsid[i] = newslist.getCatID();
        if (catsid[0] != 9)
            this.setRowHeight( localimage.getHeight() + 10);
        else
            this.setRowHeight( highest + 10);
    }
    initCallbackListening();
}

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.setColor(Color.WHITE);
        if (catsid[0] != 9) {
            graphics.drawBitmap(
                    Display.getWidth() - localimage.getWidth() - 5,
                    y
                            + ((listField.getRowHeight() - localimage
                                    .getHeight()) / 2),
                    localimage.getWidth(), localimage.getHeight(),
                    imagebitmap[index], 0, 0);
        } else {
            graphics.drawBitmap(
                    Display.getWidth() - imagebitmap[index].getWidth() - 5,
                    y
                            + (listField.getRowHeight() - imagebitmap[index]
                                    .getHeight()) / 2,
                    imagebitmap[index].getWidth(),
                    imagebitmap[index].getHeight(), imagebitmap[index], 0,
                    0);
        }
        graphics.drawRect(0, y, width, listField.getRowHeight());

        graphics.setColor(Color.BLACK);
        Vector text = Config_GlobalFunction.wrap(title[index],
                Display.getWidth() - imagebitmap[index].getWidth() - 10);
        for (int i = 0; i < text.size(); i++) {
            int liney = y + (i * Font.getDefault().getHeight());
            graphics.drawText((String) text.elementAt(i), 5, liney + 3,
                    DrawStyle.TOP | DrawStyle.LEFT | DrawStyle.ELLIPSIS,
                    Display.getWidth() - imagebitmap[index].getWidth() - 10);
        }

        graphics.setColor(Color.GRAY);
        graphics.drawText(date[index], 5, y + Font.getDefault().getHeight()
                * text.size());

        if (islatest) {
            graphics.setColor(Color.RED);
            graphics.drawText(category[index], Font.getDefault()
                    .getAdvance(date[index]) + 15, y
                    + Font.getDefault().getHeight() * text.size());
        }
    }

    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) {
    final int index = getCurrentPosition();
    Main.getUiApplication().pushScreen(new Custom_LoadingScreen(1));
    Main.getUiApplication().invokeLater(new Runnable() {
        public void run() {
            if (catsid[index] == 9) {
                if (Config_GlobalFunction.isConnected()) {
                    webpage = new BrowserField();

                    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]));
        }
    }, 1 * 1000, false);
    return true;
}
}

I tried set with this.setRowHeight(i, highest + 10);. It return wrong size of height and still every row same height.

I believe there was some tricky part and blackberry does not support for set different row height.

  • 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-08T12:37:24+00:00Added an answer on June 8, 2026 at 12:37 pm

    To set dynamic row height, it must call again in listfieldcallback()

    public class Custom_ListField extends ListField {
    private String[] title, category, date, imagepath;
    private int[] newsid, catsid;
    private List_News newslist;
    private Bitmap imagebitmap[], localimage = Config_GlobalFunction
            .Bitmap("image_base.png");
    private BrowserField webpage;
    private boolean islatest;
    
    private Vector content = null, text;
    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();
            catsid[i] = newslist.getCatID();
    
            if (!imagepath[i].toString().equals("no picture")) {
                imagebitmap[i] = Util_ImageLoader.loadImage(imagepath[i]);
            }
        }
        initCallbackListening();
    }
    
    private void initCallbackListening() {
        callback = new ListCallback();
        this.setCallback(callback);
        this.setRowHeight(-2);
    }
    
    private class ListCallback implements ListFieldCallback {
        public ListCallback() {
    
        }
    
        public void drawListRow(ListField listField, Graphics graphics,
                int index, int y, int width) {
            currentPosition = index;
            setBackground(BackgroundFactory.createBitmapBackground(
                    Bitmap.getBitmapResource("background_news_list.png"),
                    Background.POSITION_X_LEFT, Background.POSITION_Y_TOP,
                    Background.REPEAT_SCALE_TO_FIT));
    
            if (!imagepath[index].toString().equals("no picture")) {
                float ratio = (float) ((float) localimage.getHeight() / (float) imagebitmap[index]
                        .getHeight());
                Bitmap temp = new Bitmap(
                        (int) (imagebitmap[index].getWidth() * ratio),
                        (int) (imagebitmap[index].getHeight() * ratio));
                imagebitmap[index].scaleInto(temp, Bitmap.FILTER_BILINEAR,
                        Bitmap.SCALE_TO_FIT);
                imagebitmap[index] = temp;
    
                graphics.drawBitmap(
                        Display.getWidth()
                                - localimage.getWidth()
                                - 5
                                + ((localimage.getWidth() - imagebitmap[index]
                                        .getWidth()) / 2),
                        y
                                + (listField.getRowHeight(index) - localimage
                                        .getHeight()) / 2,
                        imagebitmap[index].getWidth(),
                        imagebitmap[index].getHeight(), imagebitmap[index], 0,
                        0);
    
                graphics.setColor(Color.BLACK);
                text = Config_GlobalFunction
                        .wrap(title[index], Display.getWidth()
                                - imagebitmap[index].getWidth() - 10);
    
                for (int i = 0; i < text.size(); i++) {
                    int liney = y + (i * Font.getDefault().getHeight());
                    graphics.drawText(
                            (String) text.elementAt(i),
                            5,
                            liney + 3,
                            DrawStyle.TOP | DrawStyle.LEFT | DrawStyle.ELLIPSIS,
                            Display.getWidth() - imagebitmap[index].getWidth()
                                    - 10);
                }
            } else {
                graphics.setColor(Color.BLACK);
                text = Config_GlobalFunction.wrap(title[index],
                        Display.getWidth() - 10);
                for (int i = 0; i < text.size(); i++) {
                    int liney = y + (i * Font.getDefault().getHeight());
                    graphics.drawText(
                            (String) text.elementAt(i),
                            5,
                            liney + 3,
                            DrawStyle.TOP | DrawStyle.LEFT | DrawStyle.ELLIPSIS,
                            Display.getWidth() - 10);
                }
            }
    
            if (text.size() == 2) {
                graphics.setColor(Color.GRAY);
                graphics.drawText(date[index], 5, y
                        + Font.getDefault().getHeight() + 3);
    
                if (islatest) {
                    graphics.setColor(Color.RED);
                    graphics.drawText(category[index], Font.getDefault()
                            .getAdvance(date[index]) + 15, y
                            + Font.getDefault().getHeight() + 3);
                }
            } else if (text.size() == 3) {
                graphics.setColor(Color.GRAY);
                graphics.drawText(date[index], 5, y
                        + Font.getDefault().getHeight() * 2 + 3);
    
                if (islatest) {
                    graphics.setColor(Color.RED);
                    graphics.drawText(category[index], Font.getDefault()
                            .getAdvance(date[index]) + 15, y
                            + Font.getDefault().getHeight() * 2 + 3);
                }
            }
    
            if (!imagepath[index].toString().equals("no picture")) {
                setRowHeight(index, imagebitmap[index].getHeight() + 10);
            } else {
                if (text.size() == 2)
                    setRowHeight(index, getRowHeight() + 9);
                else if (text.size() == 3) {
                    setRowHeight(index, getRowHeight() * 15 / 10 + 9);
                }
            }
    
            graphics.setColor(Color.WHITE);
            graphics.drawRect(0, y, width, listField.getRowHeight(index));
        }
    
        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) {
        final int index = getCurrentPosition();
        Main.getUiApplication().pushScreen(new Custom_LoadingScreen(1));
        Main.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                if (catsid[index] == 9) {
                    if (Config_GlobalFunction.isConnected()) {
                        webpage = new BrowserField();
    
                        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]));
            }
        }, 1 * 1000, false);
        return true;
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a screen which call a listfield . public class Main_AllLatestNews extends MainScreen
Seems I've outdone myself. All the while I was creating this pretty little 'latest
This is in relation to latest Juno or 4.2 release of Eclipse . I
I have install the latest Xcode but this keep occurring. How could I solve
This is what i want to do: I want /summary.php to include 5 latest
I really need help this time - Joomla 2.5 and latest K2. I'm using
I have this question because I am not familiar latest generation of MS VS
I know this will let the user retrieve the latest 10 posts from cocacola
Someone told me to do this in order to keep track of latest people
Has anyone got this configuration working? Latest Netbeans, latest Glassfish, I created an EJB

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.