ListField

Hello

I use a ListField and a textbox with go button

This problem only:

1 - two EditField and listField come at the top of the screen, I want it down I used Field.BOTTOM but no effect.

2. after clicking the go button the ListField must resize the size of his line by the height of the content

3 - after sending text 4 or 5 and when I go to full screen top is down I want only listfield should be scrolling.

I am creting this type of application last 4 days and I searched on several forum, but nothing helped.

Please give me a good way to do

Hello

I hope my answers help you to solve the problem

(2) after clicking on the go button the ListField must resize the size of his line by the height of the content

VNA) you can set the style in the listfield constructor, use ROW_HEIGHT (I don't know his exact name)

(3) after sending text 4 or 5 and when I go to full screen top is down, I want only listfield should be scroll

VNA) add your listfield in different Manager and substitute his sublayout() and its width and its height.

You can get the code for the override of sublayout on the forum.

(1) the EditField and listField come at the top of the screen, I want it down I used Field.BOTTOM but no effect.

VNA) I am not able to understand it, because if you add editfield and then Listfield they come one after another attempt, add editfield in the part of the State of the screen, use setStatus() method.

search for it on the forum, you will get some code on how to use setStatus().

Tags: BlackBerry Developers

Similar Questions

  • Identify the index with emphasis in listfield custom

    I'm working with a custom listfield. I would like to know the index of the row that has focus, access from a menu on the screen for customization possible highlight.

    I thought it would be ListField.getSelectedIndex () but it seems that a line is selected only when you click it (or switch to selection mode).

    It doesn't seem to be a simple, API unless I'm missing something?

    Tom

    ListField.getSelectedIndex () returns the index in line with development,-1 otherwise.

    Do you have the code examples to provide?

  • ListField and table LayoutManager

    Hello.

    I think that maybe that's my problem.

    I make use of this TableLayoutmanager (that I found on this site):

    public class TableLayoutManager extends Manager{ public TableLayoutManager(){ super(0); }     public void drawRow(Graphics g, int x, int y, int width, int height){ // Arrange the cell fields within this row manager. layout(width, height); // Place this row manager within its enclosing list. setPosition(x, y); // Apply a translating/clipping transformation to the graphics // context so that this row paints in the right area. g.pushRegion(getExtent()); // Paint this manager's controlled fields. subpaint(g); g.setColor(0x00CACACA); g.drawLine(0, 0, getPreferredWidth(), 0); // Restore the graphics context. g.popContext(); } protected void sublayout(int width, int height) { // TODO Auto-generated method stub int preferredWidth = getPreferredWidth(); int preferredHeight = getPreferredHeight(); Field field = getField(0); layoutChild(field, preferredWidth - 110, preferredHeight); setPositionChild(field, 35, 12); field = getField(1); layoutChild(field, 75, preferredHeight); setPositionChild(field, preferredWidth-75, 11); setExtent(preferredWidth, preferredHeight); } public int getPreferredWidth() { return Graphics.getScreenWidth(); } // The preferred height of a row is the "row height" as defined in the // enclosing list. public int getPreferredHeight() { return getContentHeight(); } }
    

    for this ListField:

    public class MenuListField extends ListField implements ListFieldCallback { /* * This code created based on rtm4bb HomeMenuListField.java */ private Font font; TableLayoutManager[] rows; public MenuListField(){ // this number should be the same with rows = new TableRowManager[7] // or list item in item field wont show super(9); setEmptyString("sorry, No Menu", DrawStyle.HCENTER); setCallback(this); // this row height to show the height setRowHeight(36); font = Font.getDefault(); rows = new TableLayoutManager[9]; // create a table row manager rows[0] = new TableLayoutManager(); // set the menu item name rows[0].add(new RichTextField("Computer Literacy", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[0].add(new LabelField("All our Computer Literacy Options", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[0].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[1] = new TableLayoutManager(); // set the menu item name rows[1].add(new RichTextField("Office Assistant", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[1].add(new LabelField("Secretarial Courses", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[1].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[2] = new TableLayoutManager(); // set the menu item name rows[2].add(new RichTextField("Pastel", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[2].add(new LabelField("Pastel Options", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[2].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[3] = new TableLayoutManager(); // set the menu item name rows[3].add(new RichTextField("Technical", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[3].add(new LabelField("Technical Courses", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[3].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[4] = new TableLayoutManager(); // set the menu item name rows[4].add(new RichTextField("Graphic Design", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[4].add(new LabelField("Graphic Design Courses", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[4].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[5] = new TableLayoutManager(); // set the menu item name rows[5].add(new RichTextField("IT", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[5].add(new LabelField("Our IT Options", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[5].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[6] = new TableLayoutManager(); // set the menu item name rows[6].add(new RichTextField("Web Design", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[6].add(new LabelField("Web Design Courses", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[6].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[7] = new TableLayoutManager(); // set the menu item name rows[7].add(new RichTextField("Programming", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[7].add(new LabelField("Our Programming Options", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[7].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[8] = new TableLayoutManager(); // set the menu item name rows[8].add(new RichTextField("Business Admin", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[8].add(new LabelField("Business Oriented Courses", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[8].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); // create a table row manager rows[9] = new TableLayoutManager(); // set the menu item name rows[9].add(new RichTextField("Two Year", DrawStyle.ELLIPSIS)); // set the number of list items if there are any rows[9].add(new LabelField("Two Year Courses", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); rows[9].add(new LabelField("For All Prices and Course Content, Click Here!", DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.RIGHT)); } public void drawListRow(ListField listField, Graphics graphics, int index, int y, int width) { // TODO Auto-generated method stub MenuListField list = (MenuListField) listField; TableLayoutManager rowManager = list.rows[index]; rowManager.drawRow(graphics, 0, y, width, list.getRowHeight()); } 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 Graphics.getScreenWidth(); } public int indexOfList(ListField listField, String prefix, int start) { // TODO Auto-generated method stub return -1; } protected boolean trackwheelClick(int status, int time) { int index = getSelectedIndex(); // Dialog.inform("Clicked " + Integer.toString(index)); /*if( index == 0 ) { new MenuCategoryController(); } */ switch(index) { case 0: UiApplication.getUiApplication().pushScreen(new ComputerLiteracyScreen()); break; case 1: UiApplication.getUiApplication().pushScreen(new OfficeAssistantScreen()); break; case 2: UiApplication.getUiApplication().pushScreen(new PastelScreen()); break; case 3: UiApplication.getUiApplication().pushScreen(new TechnicalScreen()); break; case 4: UiApplication.getUiApplication().pushScreen(new GraphicDesignScreen()); break; case 5: UiApplication.getUiApplication().pushScreen(new ITScreen()); break; case 6: UiApplication.getUiApplication().pushScreen(new WebDesignScreen()); break; case 7: UiApplication.getUiApplication().pushScreen(new ProgrammingScreen()); break; case 8: UiApplication.getUiApplication().pushScreen(new BusinessAdminScreen()); break; case 9:      UiApplication.getUiApplication().pushScreen(new TwoYearScreen());   break; } return true; } }
    

    And I call it like:

     MenuListField mylist = new MenuListField();
    

    Now my app keeps throwing errors IndexOutOfBounds.

    I've implemented the table layout manager properly?

    Hannes

    In your situation, I think that most of the BlackBerry users expect to see a drill down, where they see a list of courses in a ListField, then click on the course to see more detail for this course in a different window.

  • ListField background color / highlight

    I am creating a ListField with a red background and white text at any time accept for when highlighted.  When highlighted I would like to highlight to change to color pink (text remains black).  In the following code, the background color is still red, however, the highlight is never fired.

    Question = new ListField()
    {

    Boolean _inFocus;

    protected void onFocus (int direction)
    {
    super.onFocus (branch);
    _inFocus = true;
    Super.Invalidate ();
    }

    protected void onUnfocus()
    {
    super.onUnfocus ();
    _inFocus = false;
    Super.Invalidate ();
    }
       
    public void paint (Graphics g)
    {
    g.setBackgroundColor (Color.RED);
    g.setColor (Color.BLACK);
    Super.Paint (g);

    If (_inFocus)
    {
    g.Clear ();
    g.setBackgroundColor (Color.RED);
    Super.Paint (g);
    }
    on the other
    {
    g.Clear ();
    g.setBackgroundColor (Color.PINK;
    Super.Paint (g);
    }
    g.setBackgroundColor (Color.PINK);
    }
    };

    If I remove the line g.setBackgroundColor (Color.RED); the work of highlighting (rose) and the text remains black, the background color of the listfield however goes to white.  Am I miggins something logic here?  Appreciate any comment.  Thank you.

    Kile

    There is a great knowledge base article ListField coloring:

    Create a color ListField

    Study the code and be creative .

    Good luck!

  • Implementing custom listener for ListField

    I'm trying to implement a listener for a custom field I created that would launch a new screen when you click on the field. However, nothing happens when I click on the custom field. I use BlackBerry Java plug-in for Eclipse, JDK 1.3 and JRE 6.0. All my code is attached. MyScreen.java contains the code where I'm trying to implement a function fieldChanged.

    //MyApp.Java
    
    package mypackage;
    
    import net.rim.device.api.system.CodeModuleManager;
    import net.rim.device.api.ui.UiApplication;
    
    /**
     * This class extends the UiApplication class, providing a
     * graphical user interface.
     */
    public class MyApp extends UiApplication
    {
        /**
         * Entry point for application
         * @param args Command line arguments (not used)
         */
        public static void main(String[] args)
        {
            CodeModuleManager.promptForResetIfRequired();
    
            // Create a new instance of the application and make the currently
            // running thread the application's event dispatch thread.
            MyApp theApp = new MyApp();
            theApp.enterEventDispatcher();
        }
    
        /**
         * Creates a new MyApp object
         */
        public MyApp()
        {
            // Push a screen onto the UI stack for rendering.
            pushScreen(new MyScreen());
        }
    }
    
    //MyScreen.java
    
    package mypackage;
    
    import net.rim.device.api.ui.container.*; //for vertical manager
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Manager;
    //import net.rim.device.api.ui.Screen;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    
    /**
     * A class extending the MainScreen class, which provides default standard
     * behavior for BlackBerry GUI applications.
     */
    public final class MyScreen extends MainScreen
    {
        /**
         * Creates a new MyScreen object
         */
        private CustomField cField;
    
        public MyScreen()
        {
            // Set the displayed title of the screen
            setTitle("My New App");
    
            cField = new CustomField("4.PNG","This is my 4th custom field!!");
            ButtonClickListener listener = new ButtonClickListener();
            cField.setChangeListener(listener);
            add(cField);
    
        }//MyScreen function
    
        class ButtonClickListener implements FieldChangeListener
        {
            public void fieldChanged(Field field, int context)
             {
                  //we need to determine which button was clicked
    
                  if(field == cField)
                      new SpeedBumpScreen();
    
             }
    
        }//ButtonClickListener
    
    }
    
    //CustomField.java
    
    package mypackage;
    
    import java.util.Vector;
    
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    
    class CustomField extends ListField implements ListFieldCallback {
        private Vector rows;
    
        public CustomField(String customImg, String customLabel) {
            super(0, ListField.MULTI_SELECT);
            setRowHeight(80);
            setEmptyString("Hooray, no items here!", DrawStyle.HCENTER);
            //setCallback(this);
    
            Bitmap p1 = Bitmap.getBitmapResource(customImg); 
    
            rows = new Vector();
    
            TableRowManager row = new TableRowManager();
    
            row.add(new BitmapField(p1));
    
            // SET THE item NAME LABELFIELD
            // if overdue, bold/underline
            LabelField item = new LabelField("item #" + customLabel,
                DrawStyle.ELLIPSIS);
    
            // overdue
            item.setFont(Font.getDefault().derive(
                Font.BOLD | Font.UNDERLINED));
            System.out.println("OVERDUE");
    
            row.add(item);
    
            // SET THE LIST NAME
            row.add(new LabelField("List Name #" + String.valueOf(1),
                DrawStyle.ELLIPSIS) {
                protected void paint(Graphics graphics) {
                    graphics.setColor(0x00878999);
                    super.paint(graphics);
                }
            });
    
            // SET THE DUE DATE/TIME
            row.add(new LabelField("Due Date #" + String.valueOf(1),
                    DrawStyle.ELLIPSIS | LabelField.USE_ALL_WIDTH
                    | DrawStyle.RIGHT) {
                protected void paint(Graphics graphics) {
                    graphics.setColor(0x00878787);
                    super.paint(graphics);
                }
            });
    
            rows.addElement(row);
    
            setSize(rows.size());
    
        } //end public CustomField()
    
        // ListFieldCallback Implementation
        public void drawListRow(ListField listField, Graphics g, int index, int y,
                int width) {
            CustomField list = (CustomField) listField;
            TableRowManager rowManager = (TableRowManager) list.rows
                .elementAt(index);
            rowManager.drawRow(g, 0, y, width, list.getRowHeight());
        } //end drawListRow()
    
        private class TableRowManager extends Manager {
    
            public TableRowManager() {
                super(0);
            } //end pulic TableRowManager
    
            // Causes the fields within this row manager to be layed out then
            // painted.
            public void drawRow(Graphics g, int x, int y, int width, int height) {
                // Arrange the cell fields within this row manager.
                layout(width, height);
    
                // Place this row manager within its enclosing list.
                setPosition(x, y);
    
                // Apply a translating/clipping transformation to the graphics
                // context so that this row paints in the right area.
                g.pushRegion(getExtent());
    
                // Paint this manager's controlled fields.
                subpaint(g);
    
                g.setColor(0x00CACACA);
                g.drawLine(0, 0, getPreferredWidth(), 0);
    
                // Restore the graphics context.
                g.popContext();
            }//end drawRow()
    
            // Arranges this manager's controlled fields from left to right within
            // the enclosing table's columns.
            protected void sublayout(int width, int height) {
                // set the size and position of each field.
                int fontHeight = Font.getDefault().getHeight();
                int preferredWidth = getPreferredWidth();
    
                // start with the Bitmap Field of the priority icon
                Field field = getField(0);
                layoutChild(field, 32, 32);
                setPositionChild(field, 0, 0);
    
                // set the item name label field
                field = getField(1);
                layoutChild(field, preferredWidth - 16, fontHeight + 1);
                setPositionChild(field, 34, 3);
    
                // set the list name label field
                field = getField(2);
                layoutChild(field, 150, fontHeight + 1);
                setPositionChild(field, 34, fontHeight + 6);
    
                // set the due time name label field
                field = getField(3);
                layoutChild(field, 150, fontHeight + 1);
                setPositionChild(field, preferredWidth - 152, fontHeight + 6);
    
                setExtent(preferredWidth, getPreferredHeight());
            }//end sublayout()
    
            // The preferred width of a row is defined by the list renderer.
            public int getPreferredWidth() {
                return Graphics.BLACK;
            }
    
            // The preferred height of a row is the "row height" as defined in the
            // enclosing list.
            public int getPreferredHeight() {
                return getRowHeight();
            }
    
        }// private class TableRowManager extends Manager 
    
        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;
        }
    
    } //end class CustomField extends ListField implements ListFieldCallback
    
    //SpeedBumpScreen.java
    
    package mypackage;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.component.RichTextField;
    import net.rim.device.api.ui.container.MainScreen;
    
    public final class SpeedBumpScreen extends MainScreen
    {
        /**
         * Creates a new HelloWorldScreen object
         */
        SpeedBumpScreen()
        {
            // Set the displayed title of the screen
            setTitle("Speed bump screen");
    
            // Add a read only text field (RichTextField) to the screen.  The
            // RichTextField is focusable by default. Here we provide a style
            // parameter to make the field non-focusable.
            add(new RichTextField("This is the speed bump screen!", Field.NON_FOCUSABLE));
        }
    
    }
    

    In addition, there is nothing in the ListField that will actually generate an event.

    Here is a simple extension to the ListField which will make "clickable".  In your FieldChangeListener you can use getSelectedindex to determine which line has the focus.

    Please ask if this isn't clear:

    public class ClickableListField extends ListField {
    
        public ClickableListField(int numberOfRows) {
            super(numberOfRows);
        }
    
        protected boolean navigationClick(int status, int time) {
            this.fieldChangeNotify(2);
            return true;
        }
    
        protected boolean touchEvent(TouchEvent message) {
            int x = message.getX( 1 );
            int y = message.getY( 1 );
            if( x < 0 || y < 0 || x > getExtent().width || y > getExtent().height ) {
                    // Outside the field
                    return false;
            }
            // If click, process Field changed
            if ( message.getEvent() == TouchEvent.CLICK ) {
                this.fieldChangeNotify(2);
                return true;
            }
            return super.touchEvent(message);
        }
    
    }
    
  • ListField: why complexity?

    Hello everyone.

    I'm trying to do something that should be very simple.  I'm doing a ListField, filling and drawing, which was not a simple task.  Now, I'm doing a row of buttons at the bottom of the ListField so that I can load or remove the selected menu item.

    I want the list to occupy the top of the page 300 pixels of the screen and scrolling in the 300 pixels, and I want the buttons to raise the low 60 pixels (locked in landscape mode).

    I tried a bunch of things:

    -paint using graphics.fillRectangle buttons, etc. and catch the touchEvent, but when the list scrolls buttons not painted at the bottom of the screen, they scroll up with the list?

    -make a child class of ListField that redraws the buttons at the bottom of the screen on drawFocus and paint, also sets the preferred height of 300px.  There is nothing to help the situation

    ANY help would be appreciated!  Thanks in advance guys!

    -paul

    I suggest you add your buttons in the status area on your screen (setStatus()).

    The trick here is that you are trying to achieve with fields, you should really use managers to do.  If you need to add your ListField to a manager who is always 300 pixels high (you can use the sublayout method to impose the operation), and let the scrolling ListField statement.  Then you must create a high 60 Manager that you add after the 300 high Manager and you add buttons to it.

    However just add your buttons to a HorizontalFieldManager and adding then the HFM to the status area should do it for you also.

    Give it a go and let us know.

  • Touch anywhere on the screen calls the ListField TouchEvent.DOWN

    Hello

    I suffer with small complex issue. In the screen of my application, I have the title bar with a labelfield and two custom buttons.

    Below the titlefield I add a list field.

    Now, I have a few complex features on the field from the list. When I click each line in the list, it should move to another screen I do using navigation, click medium. Now if I touch the rank in the list (for touch devices), it should move to another screen. And if I touch along the line of the list, it will display popup menu (custom, not by default) with option of removal and details.

            mListItem = new ListField(length, ButtonField.CONSUME_CLICK)
            {
                long touchedAt = -1;
                long HOLD_TIME = 500;
    
             // The regular getFieldAtLocation returns wrong values in open
                        // spaces in
                        // complex managers, so we override it
    //                  public int getFieldAtLocation(int x, int y) {
    //                      XYRect rect = new XYRect();
    //                      int index = getFieldCount() - 1;
    //                      while (index >= 0) {
    //                          getField(index).getExtent(rect);
    //                          if (rect.contains(x, y))
    //                              break;
    //                          --index;
    //                      }
    //                      return index;
    //                  }
                protected boolean navigationClick(int status, int time)
                {
                    // Click related functionality
                    return true;
                }
    
                protected boolean touchEvent(TouchEvent message)
                {
                    if(message.getEvent() == TouchEvent.DOWN)
                    {
                         if (getFieldAtLocation(message.getX(1), message.getY(1)) == -1)
                         {
                             Logger.out("AccountList", "Touch down: getField location");
                             return true; // kill the event
                         }
                         else
                         {
                             touchedAt = System.currentTimeMillis();
                             touchedonList = true;
                             Logger.out("AccountList", "Touch down: touched down  "+touchedonList);
                         }
                    }
                    else if(message.getEvent() == TouchEvent.UP )
                    {
    
                           if(System.currentTimeMillis() - touchedAt < HOLD_TIME && touchedonList == true)
                           {
                               touchedAt = -1; // reset
                               // Single Touch and Move to another screen
                           }
    
                           else if(touchedonList == true)
                           {
                             // Showing Menu Popup
                           }
                    }
                    return true;
    //              return super.touchEvent(message);  // Not using this as it will show the default pop up
                }
    

    And here's my reminder list field:

    public class ListCallBack implements ListFieldCallback
        {
            public void drawListRow(ListField listField, Graphics graphics, int index,
                    int y, int width) {
    
                String strdomOrg = yyyyyyy;
                String text = xxxxxx;
                Font f = FONT_FAMILY_0_SF_AS_08;
    
                int h = f.getHeight();
    //          int height = (listField.getRowHeight() - h)/2 ;
                int height = h/2 ;
                y += height;
                graphics.setFont(f);
                graphics.setColor(Color.BLACK);
                graphics.drawText(strdomOrg, 10, y, DrawStyle.ELLIPSIS, width);
                y = y + h;
                graphics.setFont(FONT_FAMILY_1_SF_AS_08);
                graphics.setColor(Color.BLACK);
                graphics.drawText(text, 10, y, DrawStyle.ELLIPSIS , width);
    
             // use the offset instead
                int offset = (listField.getRowHeight() ) >> 1;
                if (index != 0) {
                    graphics.drawLine(0, y - offset , width, y - offset);
                }
            }
    
            public Object get(ListField listField, int index) {
                // TODO Auto-generated method stub
                return mAccounts[index];
            }
    
            public int getPreferredWidth(ListField listField) {
                // TODO Auto-generated method stub
                return screenWidth;
            }
    
            public int getPreferredHeight() {
                return getContentHeight();
            }
    
            public int indexOfList(ListField listField, String prefix, int start) {
                // TODO Auto-generated method stub
                return listField.getSelectedIndex();
            }
    
        }
    

    Now the question is to come a different way:

    1. whenever I touch the buttons in title field, he calls the listfield TouchEvent.DOWN. Then the click of a button does not work. Instead, by clicking on the title bar, it moves to another screen, which is the feature click list filed.

    2. so I added the listfield at a value for money. :

    m_vfmScreen = new VerticalFieldManager(VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR)
            {
    
            protected boolean touchEvent(TouchEvent message) {
                    int event = message.getEvent();
                    if (event == TouchEvent.CLICK) {
                        if (getFieldAtLocation(message.getX(1), message.getY(1)) == -1)
                            return true; // kill the event
                        else {
                        }
                    }
                    return super.touchEvent(message);
                }
    
                // The regular getFieldAtLocation returns wrong values in open
                // spaces in
                // complex managers, so we override it
                public int getFieldAtLocation(int x, int y) {
                    XYRect rect = new XYRect();
                    int index = getFieldCount() - 1;
                    while (index >= 0) {
                        getField(index).getExtent(rect);
                        if (rect.contains(x, y))
                            break;
                        --index;
                    }
                    return index;
                }
            };
    

    While in the list key of field works. If I touch the buttons in the title bar, it does not. But if the keys become focus, this case they work.

    So I am in dilemma, what exactly the problem. Can someone please help.

    For me, there's a code unepxected in your touchEvent() - getFieldAtLocation().  If you want released supporess presses of field, I suggest you use code like this:

    protected boolean touchEvent (TouchEvent message) {}

    int x = message.getX (1);
    int y = message.getY (1);
    If (x < 0="" ||="" y=""> < 0="" ||="" x=""> getExtent () .width: y > getExtent () .height) {}
    Outside the scope
    Returns false;
    }

  • I want to change the blackberry listfield deafault accent color

    Hello

    I want to change the accent color of blackberry deafault (blue) of listfield, here is the code sample, code works fine, I want just to customize the color of the focus of the list... Please suggest me...

    package Meidcare;

    to import java.util.Enumeration;
    import java.util.Vector;

    Import net.rim.device.api.collection.util.SortedReadableList;
    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.Graphics;
    Import net.rim.device.api.ui.component.KeywordFilterField;
    Import net.rim.device.api.ui.component.KeywordProvider;
    Import net.rim.device.api.ui.component.ListField;
    Import net.rim.device.api.ui.component.ListFieldCallback;
    Import net.rim.device.api.ui.container.MainScreen;
    Import net.rim.device.api.ui.decor.BackgroundFactory;
    Import net.rim.device.api.util.Comparator;
    Import net.rim.device.api.util.StringUtilities;

    class SearchFieldDemoScreen extends screen
    {
    Vector drugs_list = new Vector();
    Image bitmap buttonleft, buttonright;
    CountryList _countryList;
    KeywordFilterField _keywordFilterField;
    int mHColor = - 1;

    public SearchFieldDemoScreen (vector drugs_list) {}
    This.drugs_list = drugs_list;
    this.getMainManager () .setBackground (BackgroundFactory.createSolidBackground (0xC2C2C2));

    buttonLeft = bitmap.getBitmapResource ("medical_pills.png");
    buttonRight = bitmap.getBitmapResource ("white_aero.png");

    _countryList = new CountryList();
    _keywordFilterField = new KeywordFilterField();

    Enumeration XmlDiffOperation = drugs_list.elements ();
    While (enumumeration.hasMoreElements ()) {}
    _countryList.addElement (new Country (enumumeration.nextElement (m:System.NET.SocketAddress.ToString (())));

    }

    try {}
    setTitle (_keywordFilterField.getKeywordField ());

    _keywordFilterField.setLabel("Find:");
    _keywordFilterField.setSourceList (_countryList, new Country.MyProvider ());
    _keywordFilterField.setCallback (new MyListFieldCallback());

    _keywordFilterField.SetFocus ();

    Add (_keywordFilterField);

    }
    catch (Exception e) {}
    System.out.println ("Exception in keyword filter field =" + e);
    }
    }

    class MyListFieldCallback implements {ListFieldCallback}

    {public drawListRow Sub (ListField listField, Graphics g, int index, int y, int width)}
    Object obj = ((KeywordFilterField) listField) .getElementAt (index);
    g.setColor (Color.BLACK);

    If (obj! = null & obj instanceof country) {}
    Point country = (country) obj;
    g.drawText (item.toString (), 20, y, DrawStyle.ELLIPSIS |) DrawStyle.HCENTER);
    g.drawLine (0, y-9, width, y-9);
    g.setColor (Color.WHITE);
    g.fillRect (0, y-9, width, 3); for 3-pixel thick seprater "line".
    g.setColor (Color.BLACK);

    } else if(index == 0) {}
    g.drawText ("* void *", 0, y);
    }

    }

    protected void drawFocus (Graphics graphics, boolean on) {}
    graphics.setColor (Color.RED);
    Paint (Graphics);
    }

    public Object get (ListField list, int index) {}
    Return drugs_list.elementAt (index);
    }

    public int getPreferredWidth (ListField list) {}
    Return Display.getWidth ();
    }

    public int indexOfList (String prefix, int start, ListField list) {}
    return 0;
    }
    }

    class CountryList extends SortedReadableList
    {
    Vector drugs_list = new Vector();

    public CountryList()
    {
    Super (new Country.CountryListComparator ());
    }

    Sub addElement (Object item)
    {
    try {}
    System.out.println ("Ankur");
    SearchFieldDemoScreen.ls2 = new ListStyleButtonSet();
    ((Field)) SearchFieldDemoScreen.ls2.add element;
    doAdd (element);
    }
    catch (Exception e) {}
    System.out.println ("Exception in Add item =" + e);
    }
    }

    }
    }

    class country
    {
    private String _countryName;

    public country (String countryName)
    {
    _countryName = countryName;
    }

    public String ToString)
    {
    Return _countryName;
    }

    public static class MyProvider implements {KeywordProvider}
    public String [] getKeywords (Object obj) {}
    Point country = (country) obj;
    return new String [] {item._countryName};
    System.out.println ("called MyProvider");
    Return StringUtilities.stringToWords (obj.toString ());
    }
    }

    public static class CountryListComparator implements comparator
    {
    public int compare (Object o1, object o2)
    {
    System.out.println ("CountryListComparator called in method compares");
    If (o1 == null | o2 == null)
    throw new IllegalArgumentException ("can't compare countries null");
    Return o1.toString () .compareTo (o2.toString ());
    }
    }
    }

    Thanks in advance...

    Oky I solved the problem...

    using the...

    {if (g.isDrawingStyleSet (Graphics.DRAWSTYLE_FOCUS))}

    change the accent color
    g.setBackgroundColor (0xDCDCDC);
    g.Clear ();
    draw text
    g.setFont (Resize.getSecondFont ());
    g.setColor (Color.BLACK);
    g.drawText (item.toString (), 20, y, DrawStyle.ELLIPSIS |) DrawStyle.HCENTER);
    }

    inside the drawListRow...

    Thank you all...

    ----------------------------------------------

    Press on as if you like it...

  • How to create a listfield with image and text?

    How can I add images in a list. In addition, I also want to display with the image, a text. How to do?

    Help, please...

    in a listfield you use drawListRow to paint each line.
    You can use drawBitmap to paint a picture and drawText to paint the text.
    There are a few samples on the basis of knowledge, take a peek.

  • ListField showing 'EMPTY' by default

    Hi all

    I did added a ListField and adding the lines based on the data. But when there is no line, then by default 1 rank is the display and display 'EMPTY' on this line.

    I don't want to show "EMPTY". How can I restrict this 'EMPTY' to display Word?

    Thank you.

    There is a setEmptyString method, I use it with success.

  • ListField selected?

    How do I know if an item is selected in a ListField? The documentation says that getSelectedIndex returns-1 if an item is not selected, but when I fill my list then check if on is selected, the following code always runs if the list contains elements.

    If (editList.getSelectedIndex () >-1) {}

    }

    When I check the value of getSelectedIndex(), it is 0 if there is no selected item, or if the first element is selected and something greater than 0 if the other items are selected. So, what is a reliable way to only do something if an item is selected in the list.

    also, really dumb question, how you define MultiSelect on a ListField?  I wonder maybe if I need that goes out to make this work as I want to and the docs don't tell how to use the fields.

    It seems that the documentation is confusing, as the ListField will return the index of the last selected element.  Take a look at this thread - you can use 'getLeafFieldWithFocus()' to determine the currently selected field and if it is not centered, assumes that the index is - 1.

    See this thread:

    Problem with the ObjectListField

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=26369

    You use MULTI_SELECT in the style of the constructor - see setting

    Public ListField (int numRows, long style)...

  • setSelectedIndex (index) on a ListField call does not set the focus to the index.

    Hi all

    I have a ListField I show in a popup. When the listField is displayed, the focus is not set to the game past index.

    Can someone please tell me what is missing here:

    ListField choiceList = new ListField() {
        protected boolean navigationClick(int status, int time) {
        int index = this.getSelectedIndex();
        fieldChangeNotify(0);
        FSApplication.getUiApplication().popScreen(FSApplication.getUiApplication().getActiveScreen());
        return super.navigationClick(status, time);
    }
    choiceList.setChangeListener((FieldChangeListener) uiFilter);
    choiceList.setCallback(new PopUpListCallback());
    add(choiceList);
    choiceList.setSelectedIndex(6);
    choiceList.setSize(choice.length, _selectedIndex);
    choiceList.setVisualState(VISUAL_STATE_ACTIVE | VISUAL_STATE_FOCUS);
    

    set the size and choices first, then the selected index.
    If this does not work, try invokelater for the index.

  • How to use ListField UI component dyanamically

    Hello friends,

    I am new to the BB

    I want to use the ListField UI component..,.

    I use SDK 5.0,

    in this section I want to add & remove items dyanamically.,.

    So please tell me how can I do this...?

    Thank you.

    Nilesh

    Depending on how you use the field, there are delete and insert options available.  You can also set the size, then the ListField together invalidate().  These options are available via the aptly named in the ListField method calls.  Take a look at it API.

    Alternatively, you can create a new ListField with your updates and replace the existing one with your new ListField.

    Everything should work these options, you must choose the one that is easiest for you.  I admit that I generally use the option replace.  .

    In any case, the documentation, try them and let us know how you go.

  • Selects a line in a ListField

    I have a ListField in my application and I want to allow the user to select several lines that are not necessarily side by side.  Selection of lines 0, 3, 5, 9 and 10 for example.  How can I allow this behavior with a ListField?

    Thank you.

    It is not supported, but you can implement it yourself (as selected by hand, paint lines create a method getSelected etc.)

  • How to use the Thread in infinite ListField

    This is my code of listfield .
    
    package mypackage;
    
    import net.rim.device.api.command.CommandHandler;
    import net.rim.device.api.command.ReadOnlyCommandMetadata;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.SeparatorField;
    import net.rim.device.api.ui.component.table.SimpleList;
    import net.rim.device.api.ui.container.MainScreen;
    
    public class SimpleListDemo extends UiApplication {
        public static void main(String[] args) {
            SimpleListDemo theApp = new SimpleListDemo();
            theApp.enterEventDispatcher();
        }
    
        public SimpleListDemo() {
            pushScreen(new SimpleListScreen());
        }
    
        class SimpleListScreen extends MainScreen {
            private SimpleList listField;
    
            public SimpleListScreen() {
                super(Manager.NO_VERTICAL_SCROLL);
                setTitle("Simple List Demo");
                add(new LabelField("Blackberry Team", LabelField.FIELD_HCENTER));
                add(new SeparatorField());
                Manager mainManager = getMainManager();
                mainManager.setMargin(0, 0, 0, 50);
    
                listField = new SimpleList(mainManager);
    

    Thread th = new Thread()
    {

    public void run()
    {
    Try
    {
    listField.add ("Mr.Sushil");
    Thread.Sleep (1000);
    listField.add ("Mr.Anantha");
    Thread.Sleep (1000);
    listField.add ("Mr.Himanshu");
    }

    catch (System.Exception e)
    {
    }

    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {
    public void run()
    {
    }});
    }};
    Th.Start ();

              listField.setCommand(new CommandHandler() {
    
                    public void execute(ReadOnlyCommandMetadata metadata,
                            Object context) {
    
                        if (listField.getFocusRow() == 0) {
                            UiApplication.getUiApplication().pushScreen(new P());
                        }
    
                    }
                }, null, null);
    
            }
    
        }
    
    }
    

    found the solution.

  • Click on the button to see the ListField

    Hi all
    Please help... I don't know what the problem
    I have two problems.
    I have the screen where BasicEditField and ButtonField... If I click Show me so ListField.

    Here is my source code...

    package com.screen;
    
    import java.util.Vector;
    import com.stepan.kutaj.bbmsearch.util.CustomListField;
    import com.stepan.kutaj.bbmsearch.util.ListRander;
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.MenuItem;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.BasicEditField;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.container.HorizontalFieldManager;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class Test extends MainScreen
    {
        private BasicEditField enterSearch;
        private ButtonField btnSearch;
        private String txtMenuAbout = "About";
        private Vector info = new Vector();
        private CustomListField myListView;
        private String Name;
        private Bitmap displayPicture = Bitmap.getBitmapResource("rounded.png");;
    
        public Test()
        {
            super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR);
    
            addMenuItem(_viewAboutMenu);
    
            this.getMainManager().setBackground(BackgroundFactory.createSolidBackground(0x00e5e5e5));
    
            Bitmap borderBitmap = Bitmap.getBitmapResource("rounded.png");
    
            VerticalFieldManager m = new VerticalFieldManager(MainScreen.NO_VERTICAL_SCROLL);
            m.setBorder(BorderFactory.createBitmapBorder(new XYEdges(12,12,12,12), borderBitmap));
    
            HorizontalFieldManager h = new HorizontalFieldManager(MainScreen.NO_VERTICAL_SCROLL);
    
            enterSearch = new BasicEditField("Search : ", "");
            btnSearch = new ButtonField("Search");
            btnSearch.setChangeListener(buttonListener);
            h.add(enterSearch);
    
            m.add(h);
            add(m);
            add(btnSearch);
    
        }
    
        public boolean onClose() {
            System.exit(0);
            return true;
        }
    
        private MenuItem _viewAboutMenu = new MenuItem(txtMenuAbout, 10, 20)
        {
           public void run()
           {
               UiApplication.getUiApplication().pushScreen(new AboutScreen());
           }
        };
    
        FieldChangeListener buttonListener = new FieldChangeListener()
        {
            public void fieldChanged(Field field, int context)
            {
                if (field == btnSearch)
                {
                    Bitmap borderBitmap = Bitmap.getBitmapResource("rounded.png");
                    VerticalFieldManager s = new VerticalFieldManager(MainScreen.NO_VERTICAL_SCROLL);
                    s.setBorder(BorderFactory.createBitmapBorder(new XYEdges(12,12,12,12), borderBitmap));
    
                        for(int in = 0; in < 4; in++)
                        {
                            Name = "Name" + in;
    
                            String listTitle = Name;
                            String listDesc = "Description: ";
                            String listDesc2 = "Desc: ";
    
                            info.addElement(new ListRander(displayPicture, listTitle, listDesc, listDesc2));
                        }
    
                    myListView = new CustomListField(info)
                    {
                        protected boolean trackwheelClick (int status, int time)
                        {
                            Dialog.alert(" Selected :" + Name);
                            return super.trackwheelClick(status, time);
                        }
                    };
    
                    s.add(myListView);
                    add(s);
                }
            }
        };
    }
    

    and my problem is when I click on the button that show me ListField and context menu... and I do not know how to disable the context menu open...

    second problem is:
    in this list I generated 4 rows with unique name

    for(int in = 0; in < 4; in++)
    {
    Name = "Name" + in;
    
    String listTitle = Name;
    String listDesc = "Description: ";
    String listDesc2 = "Desc: ";
    
    info.addElement(new ListRander(displayPicture, listTitle, listDesc, listDesc2));
    }
    

    and I want to click on line, so I have to show for this specific line name...

    myListView = new CustomListField(info)
    {
        protected boolean trackwheelClick (int status, int time)
        {
           Dialog.alert(" Selected :" + Name);
           return super.trackwheelClick(status, time);
        }
    };
    

    and I have problem of course that shows me all name lines generated only modified (for example name03).

    can you help me please?

    Thank you

    Stepan

    (1) change

    btnSearch = new ButtonField ("Search");

    TO

    btnSearch = new ButtonField ("Search", ButtonField.CONSUME_CLICK);

    (2) I would have thought that you want something like

    protected boolean trackwheelClick (int status, int time)
    {
    ListRander selectedLine = (ListRander0 (this.getSekectedIndex ()) info.elementAt;

    String name = selectedLine.getName ();

    Dialog.Alert ("Selected:" + name);
    Return super.trackwheelClick (status, time);
    }

Maybe you are looking for

  • How to reset the iCloud security code

    Can you reset the Security Code iCloud until one has the entered incorrectly too many times? (I am connected to iCloud on my MacBook and want to connect on my iPad, but am unsure of the security code to use, so I want to reset it on the MacBook.) App

  • Envy 15 t-q400: I can't shrink c drive

    Hello I bought a t-Q400 ENVY 15 yesterday. I want to shrink the C drive to 200 GB. but windows won't let me It is said: "you can not reduce the volume beyond the point where the unmovable files are located." What can I do? 10 home edition Core i7 16

  • While you wait for spare camera for 40 days. My k910 has speaker failure. : ()

    What a piece of crap... My k910 start failure involved while I'm waiting for spare camera... Call speaker is ok, but the media here totally dead speaker... It's my problemfull phone I've ever had... My past a706 and my wife s920 are problemless...

  • HP Pavilion g6-2240sa - almost the entire keyboard has stopped working. Help please!

    Hi, I have a HP Pavilion g6-2240sa with Windows 8 operating system. This morning I turned on my laptop and the keyboard was not working, I had to use the on-screen keyboard to connect (this icon narrarator was fortunately in the lower corner). Later,

  • Computer Vista starts in safe mode, it is impossible to remove malware

    'Vista' of computer starts in safe mode. AVG on and execution of 52 Trojan detections and system leave not Malbytes {sic} program remove them. I tried all of the obvious solutions. Also I can not save and restore any files there I MISS my XP! oxooccc