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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:34:55+00:00 2026-06-04T03:34:55+00:00

Can anyone please help me to create a custom drop down similar to the

  • 0

Can anyone please help me to create a custom drop down similar to the image attached in blackberry 5.0. I have used object choice field but it is coming along with label. Guide me to create custom drop down as show in image below

enter image description here

  • 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-04T03:34:58+00:00Added an answer on June 4, 2026 at 3:34 am

    I have created my customized ChoiceField, using popup Screen. Here is the below code sample

    package com.src.java.rim.ui;
    
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.ListField;
    import net.rim.device.api.ui.component.ListFieldCallback;
    import net.rim.device.api.ui.container.HorizontalFieldManager;
    import net.rim.device.api.ui.container.PopupScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    import net.rim.device.api.ui.decor.Border;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class FWCustomChoiceField extends HorizontalFieldManager {
    
        /*space between text and icon*/
        final int padding = 10;
    
        String arrowBitmapName = "arrow_state_grey_right.png";
    
        Object choice[] = null;
    
        int index = -1;
    
        String text = "Please select one option";
    
        ListField choiceField = null;
        public FWCustomChoiceField(final Object choice[]) {
    
            this.choice = new Object[choice.length];        
            this.choice = choice;
    
            choiceField = new ListField(){
                protected boolean navigationClick(int status, int time) {
    
                    Field focus = UiApplication.getUiApplication().getActiveScreen() .getLeafFieldWithFocus();
    
                    if (focus instanceof ListField) {
                        ChoicePopupScreen popup = new ChoicePopupScreen(10, 80, choice);
                        popup.setChoice(choice);                    
                        UiApplication.getUiApplication().pushScreen(popup);
                    }
                    return super.navigationClick(status, time);
                    }
            };      
    
            choiceField.setSize(1);
            choiceField.setCallback(new TestListCallback());
            add(choiceField);
        }
    
    
        public void setSelIndex(int index){
            this.index = index; 
            this.text = choice[index].toString();
            choiceField.invalidate();
        }
    
        public int getSelectedIndex(){
            return index;
        }
    
        final class TestListCallback implements ListFieldCallback {
            TestListCallback() {
            }
            public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
                Bitmap bitmap = Bitmap.getBitmapResource(arrowBitmapName);          
                int fontWidth = getFont().getAdvance(text);
                int width = Display.getWidth() ;
                int posX = (width-(fontWidth + padding + bitmap.getWidth()))/2; 
    
                int height = list.getRowHeight();
                int posY = (height - bitmap.getHeight())/2;
    
                g.drawText(text, posX, y, 0, w);
                g.drawBitmap(posX+fontWidth+padding,posY, bitmap.getWidth(), bitmap.getHeight(), bitmap, 0, 0);
            }
            public Object get(ListField listField, int index) {
                return null;
            }
            public int getPreferredWidth(ListField listField) {
                return Graphics.getScreenWidth();
            }
            public int indexOfList(ListField listField, String prefix, int start) {
                return listField.indexOfList(prefix, start);
            }
        }
    
    
    
        public class ChoicePopupScreen extends PopupScreen {
            Object []choice = null;
    
            /*holds the position for popup screen*/
            private int  _posX = 0;
            private int _posY = 0;
    
            public ChoicePopupScreen(int posx,int posy, Object[] choice) {
                /*calling super class constructor*/
                super(new VerticalFieldManager(), Field.FOCUSABLE);
    
                this.setMargin(new XYEdges(1,1,1,1));
    
                this.choice = new Object[choice.length];
                this.choice = choice;
    
                /*Setting position for popup screen*/
                _posX = posx;
                _posY = posy;
    
                /*list field customized to display as choice picker*/
                ListField choiceList = new ListField(){
                    /*list field event handling using navigation click*/
                    protected boolean navigationClick(int status, int time) {
                        /*getting the selected list index value*/
                        int index = this.getSelectedIndex();
    
                        /*returning the selected index to the main field*/
                        setSelIndex(index);
    
                        /*removing the popup screen from the screen stack*/
                        UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
    
                        /*required for event handling*/
                        return super.navigationClick(status, time);
                    }
                };
    
                /*displays the message when list is empty*/
                choiceList.setEmptyString("List is empty", DrawStyle.LEFT);
                choiceList.setSize(choice.length);
                choiceList.setCallback(new PopUpListCallback());            
                add(choiceList);
    
    
                Border border = BorderFactory.createSimpleBorder( new XYEdges(), Border.STYLE_TRANSPARENT);
                this.setBorder(border);
            }
    
            protected void  setChoice(Object []choice) {            
                this.choice = new Object[choice.length];
                this.choice = choice;
            }
    
            protected void sublayout(int width, int height) {
                super.sublayout(width, height);         
                /*setting the position for the popup screen*/
                setPosition(_posX , _posY);
            }
        }
    
        private class PopUpListCallback implements ListFieldCallback {
            PopUpListCallback() {
            }
    
            public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
                String text = choice[index].toString();
                g.drawText(text, padding, y, 0, w);
            }
    
            public Object get(ListField listField, int index) {
                return null;
            }
    
            public int getPreferredWidth(ListField listField) {
                return Graphics.getScreenWidth();
            }
    
            public int indexOfList(ListField listField, String prefix, int start) {
                return listField.indexOfList(prefix, start);
            }
        }
    }
    

    To use the above class

    String choicestrs[] = {"Opt 1", "Opt 2", "Opt 3"};
    add(new FWCustomChoiceField(choicestrs));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone please help. I'm following a tutorial found here as I have a
Can anyone please help me how to convert string to date I have 3
Can we add image together with text in a picker view? Anyone please help!
Can anyone please help me with this? I have a Windows 2008 server and
Can anyone please help me on below? I have a WSDL and some XSD
Update: How to create a out variable?Can anyone please help me find out what
can anyone please help me. I am trying to create a dynamic table with
Can anyone please help me on the following: I have created a SQL Server
Can anyone please help me to work out how to achieve the following? I
Can anyone please help me to add video controls (play, pause, forward, seekbar) to

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.