Displaying extra rows in a ListField
I'm trying to display an extra row at the top of a ListField - called "Add Item" and it almost works, but the very last row "Item 4" of my data is not displayed.

![Screenshot, 1 row is missing][1]

How would you fix this issue?

Please see my very simple test code **MyList.java** below:

    package mypackage;
    
    import java.util.*;
    import net.rim.device.api.collection.*;
    import net.rim.device.api.collection.util.*; 
    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.decor.*;
    import net.rim.device.api.util.*;
    import net.rim.device.internal.i18n.*;
    
    public class MyList extends UiApplication {
        public static void main(String args[]) {
            MyList app = new MyList();
            app.enterEventDispatcher();
        }
        
        public MyList() {
            pushScreen(new MyScreen());
        }
    } 
    
    class MyScreen extends MainScreen {
        
        ObjectListField myList = new ObjectListField() {
            public void drawListRow(ListField list,
                            Graphics g,
                            int index,
                            int y,
                            int width) {
                if (index == 0) {
                    Font i = getFont().derive(Font.ITALIC);
                    g.setFont(i);
                    g.drawText("Add Item", 0, y);
                } else {
                    String str = (String) get(this, index - 1);
                    g.drawText(str, 0, y);
                }                
            }
                            
            protected boolean navigationClick(int status, int time) {
                int index = myList.getSelectedIndex();
                String str = (index > 0 ? (String) get(this, index - 1) : "Add item");
                Status.show("You have clicked: " + str);
                return true;
            }
        };
    
        public MyScreen() {
            setTitle("How to display an extra row?");
            myList.set(new String[] { "Item 1", "Item 2", "Item 3", "Item 4", }); 
            add(myList);
        }
    }

Thank you!
Alex


  [1]: http://i.stack.imgur.com/NXMmc.png

Displaying extra rows in a ListField
===

I'm trying to display an extra row at the top of a ListField - called "Add Item" and it almost works, but the very last row "Item 4" of my data is not displayed.

![Screenshot, 1 row is missing][1]

How would you fix this issue?

Please see my very simple test code **MyList.java** below:

    package mypackage;
    
    import java.util.*;
    import net.rim.device.api.collection.*;
    import net.rim.device.api.collection.util.*; 
    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.decor.*;
    import net.rim.device.api.util.*;
    import net.rim.device.internal.i18n.*;
    
    public class MyList extends UiApplication {
        public static void main(String args[]) {
            MyList app = new MyList();
            app.enterEventDispatcher();
        }
        
        public MyList() {
            pushScreen(new MyScreen());
        }
    } 
    
    class MyScreen extends MainScreen {
        
        ObjectListField myList = new ObjectListField() {
            public void drawListRow(ListField list,
                            Graphics g,
                            int index,
                            int y,
                            int width) {
                if (index == 0) {
                    Font i = getFont().derive(Font.ITALIC);
                    g.setFont(i);
                    g.drawText("Add Item", 0, y);
                } else {
                    String str = (String) get(this, index - 1);
                    g.drawText(str, 0, y);
                }                
            }
                            
            protected boolean navigationClick(int status, int time) {
                int index = myList.getSelectedIndex();
                String str = (index > 0 ? (String) get(this, index - 1) : "Add item");
                Status.show("You have clicked: " + str);
                return true;
            }
        };
    
        public MyScreen() {
            setTitle("How to display an extra row?");
            myList.set(new String[] { "Item 1", "Item 2", "Item 3", "Item 4", }); 
            add(myList);
        }
    }

Thank you!
Alex


  [1]: http://i.stack.imgur.com/NXMmc.png
