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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:18:17+00:00 2026-06-09T23:18:17+00:00

I am developing an app in which I need to display products in an

  • 0

I am developing an app in which I need to display products in an expandable list. So I have tried an example which was given in stackoverflow… So, it is working good, but my problem is the divider that will not wrap (expand) based on content expanding, like in screen …

enter image description here

as you can see, in the screen the date2 field is not displayed properly ..
for that, is there any scrolling facility or can this expand automatically?

Here is my code

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.TouchEvent;
import net.rim.device.api.ui.Touchscreen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.NullField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

class UiMainscreen extends MainScreen implements FieldChangeListener
{
    private CustomListField cu_field[];
    private Bitmap image=null;
    int size=8;
    public UiMainscreen() {
        VerticalFieldManager vmanager=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR){
            protected void sublayout(int maxWidth, int maxHeight) {

                super.sublayout(Display.getWidth(),Display.getHeight());
                setExtent(Display.getWidth(),Display.getHeight());
            }
        };
        cu_field=new CustomListField[size]; 
        for(int i=0;i<size;i++){
            image=Bitmap.getBitmapResource("sample_"+i+".jpg");
            cu_field[i]=new CustomListField("BlackBerry models that had a built-in mobile phone, were the first models that natively ran Java, and transmitted data over the normal 2G cellular network. RIM began to advertise these devices as email-capable mobile phones rather than as 2-way pagers.", image, "jan2011", 100, 100,Color.LIGHTGREEN);
            cu_field[i].setChangeListener(this);
            vmanager.add(new SeparatorField());
            vmanager.add(cu_field[i]);
        }
        add(vmanager);
    }

    public void fieldChanged(Field field, int context) {
        // TODO Auto-generated method stub
        for(int i=0;i<size;i++){
            if(field==cu_field[i]){
                final int k=i;
                UiApplication.getUiApplication().invokeLater(new Runnable() {
                    public void run() {
                        Dialog.alert("You click on Item No "+k);
                    }
                });
            }
        }
    }
}

class CustomListField extends HorizontalFieldManager{

    private Bitmap scale_image;
    private int width=0;
    private int height=0;
    private int background_color=0;
    private BitmapField bitmap_field;
    private boolean flag=false;
    Bitmap logingBg;
    public CustomListField(String title, Bitmap image, String date,int image_width,int image_height,int background_color){
        super(NO_HORIZONTAL_SCROLL|USE_ALL_WIDTH);
        this.background_color=background_color;
        width=image_width;
        height=image_width;
        if(image!=null){
            scale_image=new Bitmap(image_width, image_height);
            image.scaleInto(scale_image, Bitmap.FILTER_LANCZOS);
            bitmap_field=new BitmapField(scale_image);
            flag=false;
            bitmap_field.setMargin(5, 5, 5, 5);
            add(bitmap_field);
        }


        VerticalFieldManager vmanager=new VerticalFieldManager(USE_ALL_WIDTH|Field.FIELD_VCENTER){
            protected void sublayout(int maxWidth, int maxHeight) {
                super.sublayout(Display.getWidth(), height);
                setExtent(Display.getWidth(), height);
            }
        };
        ///////////////////////////////////////////
       /* Bitmap logingBg = Bitmap.getBitmapResource("myorderdatebackground.png");
        HorizontalFieldManager hfm = new HorizontalFieldManager(USE_ALL_WIDTH);
        HorizontalFieldManager hfm2 = new HorizontalFieldManager(Field.FIELD_HCENTER);
        ButtonField btnext = new ButtonField("btn");
        CustomButtonField btnSignIn = new CustomButtonField(0, "", logingBg,
                logingBg, Field.FOCUSABLE, Color.WHITE);
        hfm2.add(btnext);
        hfm.add(btnSignIn);

        hfm.add(hfm2);
        vmanager.add(hfm);*/
         logingBg = Bitmap.getBitmapResource("myorderdatebackground.png");

        HorizontalFieldManager HFM = new HorizontalFieldManager(USE_ALL_WIDTH) {
            public void paint(Graphics g) {
                //g.setBackgroundColor(Color.BLUE);
                g.clear();
                g.drawBitmap(0, 0, Display.getWidth(),            
                        logingBg.getHeight(), logingBg, 0, 0);  
                super.paint(g);
            }
        };


        HorizontalFieldManager lableRegistHFM = new HorizontalFieldManager(
                FIELD_VCENTER);
        LabelField RegistrationLbl = new LabelField("My Orders",Field.FIELD_HCENTER);
        FontFamily fontFamily[] = FontFamily.getFontFamilies();
        Font font11 = fontFamily[1].getFont(FontFamily.CBTF_FONT, 12);
        font11 = fontFamily[1].getFont(Font.BOLD, 18);
        RegistrationLbl.setFont(font11);
        RegistrationLbl.setMargin(0, 0, 0, (Display.getWidth() / 3));

        lableRegistHFM.add(RegistrationLbl);

        HFM.add(lableRegistHFM);
        vmanager.add(HFM);

        /**************************************************************/

        LabelField title_lbl=new LabelField("Title: "+title,Field.NON_FOCUSABLE|DrawStyle.ELLIPSIS);
        vmanager.add(title_lbl);

        LabelField date_lbl=new LabelField("Date: "+date,Field.NON_FOCUSABLE);
        vmanager.add(date_lbl);

        LabelField date_lbl3=new LabelField("Date2: "+date,Field.NON_FOCUSABLE);
        vmanager.add(date_lbl3);

        LabelField date_lbl4=new LabelField("Date2: "+date,Field.NON_FOCUSABLE);
        vmanager.add(date_lbl4);

        Font fon=title_lbl.getFont();
        int title_height=fon.getHeight();

        Font font=date_lbl.getFont();
        int date_height=font.getHeight();
        int pad=title_height+date_height;
        title_lbl.setPadding((height-pad)/2, 0, 0, 0);
        add(vmanager);
        add(new NullField(FOCUSABLE));
    }

    protected void sublayout(int maxWidth, int maxHeight) {
        super.sublayout(Display.getWidth(), height);
        setExtent(Display.getWidth(), height);
    }
    protected void paint(Graphics graphics) {
        if(flag)
        graphics.setBackgroundColor(background_color);
        graphics.clear();
        super.paint(graphics);
    }
    protected void onFocus(int direction) {
        super.onFocus(direction);
        flag=true;
        invalidate();
    }
    protected void onUnfocus() {
        invalidate();
        flag=false;
    }
    protected boolean navigationClick(int status, int time) {

        if(Touchscreen.isSupported()){
            return false;
        }else{
            fieldChangeNotify(1);
            return true;
        }

    }
    protected boolean touchEvent(TouchEvent message) 
    {
        if (TouchEvent.CLICK == message.getEvent()) 
        {

            FieldChangeListener listener = getChangeListener();
            if (null != listener)
                this.setFocus();
                listener.fieldChanged(this, 1);
        }
        return super.touchEvent(message);
    }
}
  • 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-09T23:18:19+00:00Added an answer on June 9, 2026 at 11:18 pm

    The issue is here:

    protected void sublayout(int maxWidth, int maxHeight) {
        super.sublayout(Display.getWidth(), height);
        setExtent(Display.getWidth(), height);
    }
    

    You’re giving manager height less that it needs for content (only image_width).

    Also here is possible error:

    width=image_width;
    height=image_width;
    

    You should use image_height for the height.

    And sure you could use scrolling for VerticalManager – add style VERTICAL_SCROLL to constructor. But as user I will find the User Experience (UX) strange in this case.

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

Sidebar

Related Questions

I am developing an android app in which i need to display images after
i am developing one app in which i need to show list of product
I am developing an app in which I need a ListView whose rows have
I am developing an app which listens to incoming sms. I have added the
I have been developing an iPhone app which queries a server that relays data
Im developing a app which has a user sign-up activity, there I need to
I am developing a app for a movie in which I need to fetch
I'm developing an app where I need to get a list of files, read
I am developing an app in which I need to manage users session i.e
I am developing an app which supposed to work on devices that have OS

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.