ListField and navigationclick

Hello

I read this tutorial

http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800345/...

to create a list of items on the messaging screen.

Now, I like, when I select an item from the list, open a new screen to view other information.

How can I do?

In the development guide it is only written to use navigationclick, but I don't understand where to use it

Thank you

I tried this solution and it works:

   protected boolean navigationClick(int status, int time)
   {
       Field field = this.getFieldWithFocus();

       if(field instanceof ListField)
       {

           int selected = _listField.getSelectedIndex();
           switch (selected) {
        case 0:
            pushScreen(new Screen1());
            break;
        case 1:
            pushScreen(new Screen2());
            break;
        case 2:
            pushScreen(new Screen3());
            break;
        case 3:
            pushScreen(new Screen4());
            break;
        case 4:
            pushScreen(new Screen5());
            break;
        default:
            break;
        }
          return true;
        }

       return super.navigationClick(status, time);
   }

  }

Tags: BlackBerry Developers

Similar Questions

  • How to get the element selected listfield and goto next page?

    Assalaamualikum

    I try parsing the XML from a url and show in listfield.

    problem:

    How to get the selected item and passing the variable and than goto next page?

    my code:

    package parsepack;

    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Vector;

    Import javax.microedition.io.Connector;
    Import javax.microedition.io.StreamConnection;

    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.FieldChangeListener;
    Import net.rim.device.api.ui.Graphics;
    Import net.rim.device.api.ui.Manager;
    Import net.rim.device.api.ui.UiApplication;
    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.container.VerticalFieldManager;
    Import net.rim.device.api.xml.parsers.DocumentBuilder;
    Import net.rim.device.api.xml.parsers.DocumentBuilderFactory;

    to import org.W3C.DOM.document;
    Import org.w3c.dom.Node;
    Import org.w3c.dom.NodeList;

    extends xmlparsing public class UiApplication implements ListFieldCallback, FieldChangeListener
    {

    Public Shared Sub main (String [] args)
    {
    xmlparsing app = new xmlparsing();
    app.enterEventDispatcher ();
    }

    public long mycolor;
    Connection _connectionthread;
    private static ListField _list;
    private static Vector listElements is new Vector();.
    public display display = new MainScreen();
    MainManager VerticalFieldManager;
    VerticalFieldManager subManager;

    public xmlparsing()
    {
    Super();
    pushScreen (screen);

    final Bitmap Imagearriereplan = Bitmap.getBitmapResource ("blackbackground.png");

    mainManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL |) Manager.NO_VERTICAL_SCROLLBAR)
    {

    public void paint (Graphics graphics)
    {
    graphics.drawBitmap (0, 0, Display.getWidth (), Display.getHeight (), Imagearriereplan, 0, 0);

    Super.Paint (Graphics);
    }

    };

    subManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL |) Manager.VERTICAL_SCROLLBAR)
    {
    protected void sublayout (int maxWidth, maxHeight int)
    {
    int displayWidth = Display.getWidth ();
    int displayHeight = Display.getHeight ();

    Super.sublayout (displayWidth, displayHeight);
    setExtent (displayWidth, displayHeight);
    }
    };

    Screen.Add (mainManager);

    _list = new ListField()

    {

    public void paint (Graphics graphics)

    {
    graphics.setColor ((int) mycolor);
    Super.Paint (Graphics);

    }

    };
    myColor = 0x00FFFFFF;
    _list. Invalidate();
    _list.setEmptyString ("* only supplies not available *", DrawStyle.HCENTER "");
    _list.setRowHeight (50);
    _list.setCallback (this);
    mainManager.add (subManager);
    listElements.removeAllElements ();
    _connectionthread = New Connection();
    _connectionthread. Start();
    }

    protected boolean navigationClick (int status, int time)
    {
    Try
    {
    Here, go to another screen if you need.

    }
    catch (System.Exception e)
    {
    System.out.println ("Exception:-: navigationClick()" + try ());
    }
    Returns true;
    }

    private class login extends thread
    {
    Public connection()
    {
    Super();
    }

    public void run() {}
    Doc document;
    StreamConnection conn = null;
    InputStream is = null;
    try {}

    Conn = Connector.open (StreamConnection) ("http://ec2-54-248-241-248.ap-northeast-1.compute.amazonaws.com/koperasi-akr-trial/cgi-bin/gw-pinjama...

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance ();
    docBuilderFactory.setIgnoringElementContentWhitespace (true);
    docBuilderFactory.setCoalescing (true);
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder ();
    docBuilder.isValidating ();
    is = conn.openInputStream ();
    doc = docBuilder.parse (is);
    doc.getDocumentElement () .normalize ();
    List of NodeList = doc.getElementsByTagName ("ID");
    for (int i = 0; i)< list.getlength();="" i++)="">
    Node node = list.item (i) .getFirstChild ();
    listElements.addElement (textNode.getNodeValue ());
    }
    } catch (Exception e) {}
    System.out.println (try ());
    } {Finally
    If (is! = null) {}
    try {is.close ();
    } catch (IOException ignored) {}
    } If (conn! = null) {}
    Try {conn.close () ;}
    catch (IOException ignored) {}
    }} UiApplication.getUiApplication () .invokeLater (new Runnable() {}
    public void run() {}
    _list. SetSize (listElements.Size ());
    subManager.add (_list);
    Screen.Invalidate ();
    }
    });
    }

    }

    ' public void drawListRow (list ListField, Graphics g, int index, int y, int w)
    {
    Your string = (String) listElements.elementAt (index);
    int yPos = 0 + y;
    g.drawLine (0, yPos, w, yPos);
    g.drawText (, 5, 15 + y, 0, w);
    }

    public {get {Object (ListField list, int index)
    {
    Return listElements.elementAt (index);
    }
    public int indexOfList (String prefix, ListField list, int, string)
    {
    Return listElements.indexOf (prefix, string);
    }
    public int getPreferredWidth (ListField list)
    {
    Return Display.getWidth ();
    }
    public final void insert (String toInsert, int index) {}
    listElements.addElement (toInsert);
    }

    ' Public Sub fieldChanged (field field, int context) {}

    }
    }

    Thank you.

    I told you that replace the navigationclick() method where initialize you your listfield

    as I think that changing your code and then answer me

    _list = new ListField()
    {
    protected boolean navigationClick(int status, int time)
    {
      Dialog.inform("hi");
      return true;
    }
    
    public void paint(Graphics graphics)
    {
    graphics.setColor((int) mycolor);
    super.paint(graphics);
    }
    };
    
  • 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.

  • Problem with Listfield and expandable background bitmap

    Hello

    I struggled for a while to make this work, and after searching the forums and knowledge base, I can't seem to do right. What I try to do is:

    1 header is a bitmap expandable width of 1px to the bottom, more a company logo bitmap, with position fixed (only the items below it is scrolling)

    2. use a listfield, which contains 4 elements:

    -1 px wide image bitmap background for each line, repeat horizontally

    -1 px width bitmap image of background for the highlighted line, repeat horizontally

    -an icon bitmap for each line on the left side, and

    -a title text for each line

    Here is the screenshot and code what I've done so far, so the problem is:

    1. when I scroll, scrolls the header (what I want is to position of the header is fixed, only the listfield below is scrolling).

    2. the background image is only painted on the first line of the listfield, how can I do this with all the lines?

    3. How is - that replace you the default blue color on a bitmap background highlighted line?

    public class AjsScreen extends MainScreen{
    
        // constructor
        public AjsScreen() {
            super();
    
            // --- 1. Main Header --- \\
    
            //prepare images upfront
            final Bitmap bgHeader = Bitmap.getBitmapResource("bg-header.jpg"); // repeating background image for main header
            final Bitmap logoAjs = Bitmap.getBitmapResource("logo-ajs.png"); // company logo in main header
            final Bitmap bgMenu = Bitmap.getBitmapResource("bg-menu.jpg"); // repeating background image for main menu
            final Bitmap bgMenuRo = Bitmap.getBitmapResource("bg-menu-ro.jpg"); // repeating background image for main menu (highlighted)
    
            //images used as repeating background
            final Background backgroundHeader = BackgroundFactory.createBitmapBackground(bgHeader, 0, 0, Background.REPEAT_VERTICAL); //REPEAT HORIZONTAL ???
            Background backgroundMenu = BackgroundFactory.createBitmapBackground(bgMenu, 0, 0, Background.REPEAT_VERTICAL);
            Background backgroundMenuRo = BackgroundFactory.createBitmapBackground(bgMenuRo, 0, 0, Background.REPEAT_VERTICAL);
    
            //main header background, with stretched width, and fixed height
            HorizontalFieldManager hfm = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH){
                public int getPreferredHeight() {
                    return 55;
                }
            };
            hfm.setBackground(backgroundHeader);
    
            //main header logo
            BitmapField bf = new BitmapField(logoAjs);
            bf.setPadding(2, 0, 0, 5);//clockwise from top, right, bottom, left
            hfm.add(bf);
    
            add(hfm);
    
            // --- 2. Main Menu --- \\
    
            ListField lf = new ListField(){ //4, USE_ALL_HEIGHT | USE_ALL_WIDTH
                protected void paint(Graphics graphics) {
                    // TODO Auto-generated method stub
                    super.paint(graphics);
                }
            };
            lf.setBackground(backgroundMenu);
            lf.setRowHeight(40);
    
            final Vector le = new Vector();
            le.addElement("Menu 1");
            le.addElement("Menu 2");
            le.addElement("Menu 3");
            le.addElement("Menu 4");
            le.addElement("Menu 5");
            le.addElement("Menu 6");
            le.addElement("Menu 7");
            le.addElement("Menu 8");
            le.addElement("Menu 9");
    
            lf.setCallback(new ListFieldCallback() {
                public int indexOfList(ListField listField, String prefix, int string) {
                    return le.indexOf(prefix, string);
                }
                public int getPreferredWidth(ListField listField) {
                    return Display.getWidth();
                }
                public Object get(ListField listField, int index) {
                    return le.elementAt(index);
                }
                public void drawListRow(ListField listField, Graphics g, int index, int y, int w) {
                    g.drawBitmap(0, y, bgMenu.getWidth(), bgMenu.getHeight(), bgMenu, 0, 0);
    
                    String text = (String) le.elementAt(index);
                    g.drawText(text, 0, y, 0, w);
                }
            });
    
            lf.setSize(le.size());
    
            add(lf);
    
        }
    
    }
    

    Thank you very much

    Yusuf

    «1. when I scroll, scrolls the header (what I want is in the position of the header is fixed, only the listfield below scrolls).»

    ListField will do this for you.  I suggest that you look at setTitle in the screen and put your part not scrolling in there

    '2. the background image is only painted on the first line of the listfield, how can I do this with all the lines?'

    Don't know (haven't looked hard) how your background is painted on the first line, but this line:

    g.drawBitmap (0, bgMenu.getWidth (), bgMenu.getHeight (), bgMenu, 0, 0);

    doesn't seem to work for your lines.  You need to paint the entire width like this.

    ". How do replace you line default highlighted in blue on a background bitmap? »

    There are a number of ways to do I think.  Is to determine if you paint the selected line and act accordingly

    (if (listField.getSelectedInde () == index) {...})

    } else {}

    }

    Some people I think drawFocus override for the ListField - if you're looking for tour you will find examples.

    I think there are other ways, I'm looking round I think that this question has been asked before.

  • bitmap image clears I scroll in the listfield and not repainted

    Hi all

    I try to use a single bitmap for the listfield, who owns 10 list (for example). I am just placing bitmap b4 but it erases just the user scrolls and don't then repainted. Please help me find the solution.

    public MyCallback()
        {
            dest = new XYRect(5,5,20,20);
            bitmap = Bitmap.getBitmapResource("icon_select.png");
        }
    
        public void drawListRow(ListField listField, Graphics graphics, int index,
                int y, int width)
        {
            String text = (String) list.elementAt(index);
            dest.y+=15;
            graphics.drawBitmap(dest, bitmap, 0, 0);
            graphics.drawText(text,25, y+3,0,width);
        }
    

    also how to make this bitmap appears as it is b4 every name I.

    This is b4 scrolling. and after scrolling it looks like.

    Please help me find the solution

    average u when focus you and unfocus the individual line.

    If it's problem so look for drawFocus, u can try calling inavalidate inside...

    can u post a larger excerpt

  • Refresh ListField and store multiple entries

    I'm having a problem trying to get my program to save the information. I recently ended show him an entry but I don't think that im doing something because it shows just the same entry over and over again.

    Im trying to to save all fees in the form of spending and then display them in the WelcomeScreen listbox. I'll include the store file, welcomeScreen and booking fees.

    What would be the best way to store this information and display them in the listfield? Also when you return to the WelcomeScreen how can I have the update so the listfield is updated?

    WelcomeScreen:

    package moneyMasterApp;
    
    import java.util.Vector;
    
    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.*;
    
    public class WelcomeScreen extends UiApplication implements StoreResource {
        //Declare Variables
        //create a button here with the text 'Submit!'
            //ButtonField.CONSUME_CLICK will prevent the Menu from showing up when the user clicks the button.
            ButtonField btnDeposit = new ButtonField("Deposit", Field.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
            ButtonField btnExpense = new ButtonField("Expense", Field.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
            UiApplication nxtscreen = UiApplication.getUiApplication();
            HorizontalFieldManager _FieldManagerTop;
            LabelField myTitleLabel;
            BitmapField bitpam = new BitmapField();
            Background bg;
            LabelField label = new LabelField("Please Select Action:");
            FieldListener listener = new FieldListener();
            private static Vector _data;
            private static PersistentObject store;
            private ListField ExpenseList = new ListField();
    
        public static void main(String[] arg) {
            WelcomeScreen app = new WelcomeScreen();
            app.enterEventDispatcher();
        }
    
        public WelcomeScreen() {
            MainScreen mainScreen = new MoneyMakerMainScreen();
            //Set the title of the screen
            mainScreen.setTitle("MoneyMaster");
            //Add labels and other items
            _FieldManagerTop = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
            myTitleLabel = new LabelField("MoneyMaster");
            bitpam = new BitmapField();
            bitpam.setBitmap(Bitmap.getBitmapResource("bbicon.png"));
            _FieldManagerTop.add(myTitleLabel);
            _FieldManagerTop.add(bitpam);
            bg = BackgroundFactory.createLinearGradientBackground(0x2ebaeb, 0x2ebaeb, 0x7cbaed, 0x7cbaed);
            mainScreen.getMainManager().setBackground(bg);
    
            synchronized(store) {
                Vector _data = (Vector) store.getContents();
                int count = _data.size();
                ExpenseList.setEmptyString("Nothing", DrawStyle.LEFT);
                ExpenseList.setSize(count);
            }
    
            ExpenseList.setCallback(new ExpenseListCallback());
    
            //Add objects to screen
            mainScreen.add(_FieldManagerTop);
            mainScreen.add(label);
            mainScreen.add(new SeparatorField());
            btnDeposit.setChangeListener(listener);
            btnExpense.setChangeListener(listener);
            mainScreen.add(btnDeposit);
            mainScreen.add(btnExpense);
            mainScreen.add(new SeparatorField());
            mainScreen.add(ExpenseList);
            pushScreen(mainScreen);
    
        }
    
        static {
            //Retrieve a reference to a persistent object
            //and set its contents to a new new vector if it is empty
            store = PersistentStore.getPersistentObject(0xe69c43e620187619L);
            //Hash of: "TechStormSolutions.MoneyMaster.Application"
            synchronized(store) {
                if (store.getContents() == null) {
                    store.setContents(new Vector());
                    store.commit();
                }
            }
            //retrieve the contents of the PersistentObject
            //and store in a Vector
            _data = new Vector();
            _data = (Vector)store.getContents();
        }
    
        private final class MoneyMakerMainScreen extends MainScreen {
            protected void makeMenu (Menu menu, int instance) {
                menu.add(deposit);
                menu.add(expense);
                super.makeMenu(menu, instance);
            }
    
            public void close() {
                Dialog.alert("Closing Application");
                super.close();
            }
        }
    
        private MenuItem deposit = new MenuItem("Deposit", 1, 100) {
            public void run() {
                UiApplication.getUiApplication().pushScreen(new depositForm());
            }
        };
        private MenuItem expense = new MenuItem("Expense", 2, 101) {
            public void run() {
                UiApplication.getUiApplication().pushScreen(new expenseForm());
            }
        };
    
        class FieldListener implements FieldChangeListener {
    
            public void fieldChanged(Field f, int context) {
                //if the deposit button is clicked
                if (f==btnDeposit) {
                    UiApplication.getUiApplication().pushScreen(new depositForm());
                };
                if (f==btnExpense) {
                    UiApplication.getUiApplication().pushScreen(new expenseForm());
                }
            }
    
        }
    
        final class ExpenseListCallback implements ListFieldCallback {
    
            public void drawListRow(ListField list, Graphics g,
                    int index, int y, int w) {
                int count = _data.size();
    
                synchronized(store) {
                    Vector _data = (Vector) store.getContents();
                    if (!_data.isEmpty()) {
                        String[] ExpList = new String[count];
                        for (int i = 0; i < count; ++i) {
                            StoreInitial info = (StoreInitial) _data.elementAt(i);
                            ExpList[i] = info.getElement(StoreInitial.AMOUNT);
                        }
    
                        g.drawText(ExpList[0], 0,y,0,w);
                    }
                }
    
            }
    
            public Object get(ListField listField, int index) {
                return null;
            }
    
            public int getPreferredWidth(ListField listField) {
                return Display.getWidth();
            }
    
            public int indexOfList(ListField listField, String prefix, int start) {
                return listField.indexOfList(prefix, start);
            }
    
        }
    }
    

    In my listcallback I had to change that loop and out so that the index was the counter.

    synchronized(store) {
                    Vector _data = (Vector) store.getContents();
                    if (!_data.isEmpty()) {
                        String[] ExpList = new String[index];
                        StoreInitial info = (StoreInitial) _data.elementAt(i);
                        g.drawText(info.getElement(StoreInitial.AMOUNT), 0,y,DrawStyle.RIGHT,w);
                    }
                }
    
  • TreeField and navigationClick for expand/collapse?

    I'm doing a MSN Messenger or Google Chat interface on blackberry. One of the functions they have is a TreeField that when a parent is clicked above immediately develop or reduced the subtree.  By default, TreeField seems to open a menu where it actually have to highlight, and then click to expand or collapse.

    Is the best way to implement a single click to open/close using the method of the TreeField navigationClick?

    Anyone with the code example?

    Thank you.

    NavigationClick using should work fine. This should be close:

    protected boolean navigationClick(int status, int time) {
      // we'll only override unvarnished navigation click behavior
      if ((status & KeypadListener.STATUS_ALT) == 0 &&
          (status & KeypadListener.STATUS_SHIFT) == 0)
      {
        int node = getCurrentNode();
        if (getFirstChild(node) != -1) {
          // node is an internal node
          setExpanded(node, !getExpanded(node));
          return true;
        } else {
          // click is on a leaf node. Do some default action or else fall through
        }
      }
      return super.navigationClick(status, time);
    }
    

    It can also function as a method on a form that contains only a single TreeField (after that change of all TreeField method calls while they are called on a variable of TreeField rather than on this).

  • Scrolling AND selecting items in a ListField on the storm?

    Background information:

    BlackBerry Storm 9500

    BlackBerry JDE 4.7.0

    Problem:

    I use a ListField to display several items in a list. I also use the touchEvent (TouchEvent message) method to listen to a click (TouchEvent.CLICK). Well, everything seems to work except when I need to scroll through the list. It seems that using the touchEvent method, I can't scroll through the list. If I remove the touchEvent method, scrolling works but I am unable to use the touch interface to select an item in the list by clicking on it.

    Question:

    Is it possible to get both? In other words, can enable scrolling in the ListField AND allow the user to select an item by clicking on it?

    Code:

    private class SlideList extends screen

    {

    Fields

    private ListField _list;

    Private _callback ListCallback;

    Constructor

    public SlideList()

    {

    Super();

    Add a title screen

    LabelField title = new LabelField (getTitle (), LabelField.ELLIPSIS |) LabelField.USE_ALL_WIDTH);

    setTitle (title);

    setupList();

    }

    Private Sub setupList()

    {

    If (_list! = null)

    Delete (_list);

    Get all the slides and put their titles and subtitles in a table

    String [] slideTitles = getSlideTitles();

    _list = new ListField();

    _callback = new ListCallback();

    _list.setCallback (_callback);

    Build the list of exercise.

    for (int index = 0; index)

    {

    _list. Insert (index);

    _callback. Insert (slideTitles [index], index);

    }

    _list.setSelectedIndex (currentSlideNum);

    Add (_list);

    }

    Get the touch input.

    protected boolean touchEvent (TouchEvent message)

    {

    If (message.getEvent () is TouchEvent.CLICK)

    {

    Check if a list item is selected.

    If (_list.getSelectedIndex () > - 1).

    {

    Dialog.Alert ("you selected:" + _list.getSelectedIndex ());

    itemSelected (_list.getSelectedIndex ());

    Returns true;

    }

    on the other

    Returns false;

    }

    on the other

    Returns false;

    }

    Private Sub itemSelected (int listIndex)

    {

    currentSlideNum = listIndex;

    displaySlide();

    UiApplication.getUiApplication () .popScreen (this);     Remove this screen to display the program.

    }

    private class ListCallback implements {ListFieldCallback}

    private vector listElements = new Vector();

    ' public void drawListRow (list ListField, Graphics g, int index, int y, int w)

    {

    String text = (String) listElements.elementAt (index);

    g.drawText (text, slideIcons [index] .getWidth () + 10, y, 0, w);

    }

    public Object get (ListField list, int index) {}

    Return listElements.elementAt (index);

    }

    public int indexOfList (String p, ListField list, int s) {}

    Return listElements.getSelectedIndex ();

    Return listElements.indexOf (p, s);

    }

    public int getPreferredWidth (ListField list) {}

    Display sr = UiApplication.getUiApplication () .getActiveScreen ();

    Return sr.getWidth ();

    }

    public final void insert (String toInsert, int index) {}

    listElements.insertElementAt (toInsert, index);

    }

    {} public void erase()

    listElements.removeAllElements ();

    }

    }

    }

    Mark,

    Thanks for your reply. It turns out that the solution I was looking for was very simple. Rather than return

    fake

    in the touchEvent method, I back

    super.touchEvent (message)

    While touchEvent can call its parent class and always look for other events inherent in a listenField, such as scrolling with a finger.

    It now looks like this:

    Get the touch input.

    protected boolean touchEvent (TouchEvent message)

    {

    If (message.getEvent () is TouchEvent.CLICK)

    {

    Check if a list item is selected.

    If (_list.getSelectedIndex () > - 1).

    {

    Dialog.Alert ("you selected:" + _list.getSelectedIndex ());

    itemSelected (_list.getSelectedIndex ());

    Returns true;

    }

    }

    Return super.touchEvent (message);

    }

  • Weird behavior of ListField on touch devices

    Hello!

    I have a custom ListField, who has a weird behavoid on palpable devices like the torch and storm. I try to move it with my fingers but it does weird things. If it happened to someone else?

    Thank you!

    My code is:

    public class FancyList extends ListField implements ListFieldCallback, Runnable, ItinetoursResource {
        private Vector rows;
        private Vector rutas;
        private String[] tags;
        private String[] avatars;
        private Bitmap[] fotos;
        private ResourceBundle res;
        private int fotoActual=-1;
        private static final int rowHeight=70;
    
        public FancyList(Vector rutas) {
            super(0, ListField.MULTI_SELECT);
            this.rutas = rutas;
            setRowHeight(rowHeight);
            res = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
            setEmptyString(res.getString(FANCY_LIST_NINGUN_TOUR_ENCONTRADO), DrawStyle.HCENTER);
            setCallback(this);
    
            avatars = new String[rutas.size()];
            tags = new String[rutas.size()];
            fotos = new Bitmap[rutas.size()];
    
            for(int i=0; i			 

    As far as I KNOW, the mechanism of scrolling, you talk about work out of the box with a standard ListField.  Have you tried to use a ListField standard to see if you can make it work?

    I suspect that your code passes very slowly, because of the significant workload in the painting of each line.  I think that if you've tried this code on a trackpad device, you would have problems scrolling too, have you actually tried on another device?

    With regard to obtaining click events working on a ListField, you can find the following useful code.  Using this, you can add a FieldChangeListener to the ListField and it will go through standard fieldChanged code when it is selected.

    /**
    * Simple extension of the ListField designed to
    FieldChangeListener disk on "click here".
    *
    To examine the methods of field substituted here for more information.
    */

    Import net.rim.device.api.ui.component.ListField;
    Import net.rim.device.api.ui.TouchEvent;

    SerializableAttribute public class ClickableListField extends {ListField

    public ClickableListField (int numberOfRows) {}
    Super (numberOfRows);
    }

    protected boolean navigationClick (int status, int time) {}
    this.fieldChangeNotify (2);
    Returns true;
    }

    protected boolean touchEvent (TouchEvent message) {}
    If click process changed field
    If (message.getEvent () == TouchEvent.CLICK) {}
    this.fieldChangeNotify (2);
    Returns true;
    }
    Return super.touchEvent (message);
    }

    }

  • ListField - how to get the selected items

    Hi @all,

    I am running OS5 on a BB bold 9700 and development via eclipse.

    I tried to do a listfield and put it in a display of network manager, which works very well.

    As peter_strange did in a reply to a thread listfield, I tried to catch the click button on navigation through "makemenu.

    It works fine, but after processing the code according to the listfield (getindex), it shows a standard menu, which I don't want. I want just to get the index or the name of the current or selected fields and continue with the transformation by showing a new screen for example.

    In some other threads that I found excerpts concerning 'navigationclick', but I don't understand, what I have to do here and why. Th KB, I searched but I did find something to go further.

    Someone there who can help me with a small example?

    Thank you much in advance.

    CUA

    Michael

    You can create your own class or override her anonymously.

    new ListField (...) {replace the code of the method here}

    (blackberry is perhaps not the best way to start learning java...)

  • Point ListField

    Hello

    After I have insert an element into a listfield using the insert() function.

    How can I get the answer when I use the wheel to click on it.

    For example.

    I have a list

    Tom

    John

    Grace

    When I scroll using the wheel of John, I want to be able to open as a pop-up window or to an action.

    or is there another method I can use to display a list of names and to allow the user to click on a name with the wheel?

    use of navigation click method... I send you some sample code substitute your name of listfield and use it...

    protected boolean navigationClick(int status, int time) {
    
             Field field = this.getFieldWithFocus();
             if(field.equals(eventListField)){
                 int index = eventListField.getSelectedIndex();
    
        // Do some thing here what you want with that index...          //UiApplication.getUiApplication().pushScreen(new DetailPage((Event) eventList.elementAt(index)));
    
             }
            return super.navigationClick(status, time);
        }
    
  • CustomListField + CustomButtonField + touchEvent + NavigationClick is HELL

    Hello world

    I'm doing this thing works

    I have a screen which consists of three components

    HEADER

    -a custom refresh button (extends the scope with a bitmap and override touchEvent and navigationClick)

    CONTENT

    -NavigationClick and custom touchEvent ListField and substitution

    FOOTER

    -Type of a menu with several button (application as well as for the header)

    When I run my screen, the focus is made on the footer, so I can use my buttons

    If I click on the listField or even make dragging, then the listField component get the Focus.

    Now, when I touch one of my footer button, only the method of the ListField touchEvent's launch, even if I return false in everycase, neither the toucheEvent nor my footer buttons navigationClick method will be called.

    So if I click on my footer, I see only the listField slips a little and nothing else.

    Anyone experienced the same thing?

    This BlackBerry bug has already been reported and confirmed by RIM on this forum:

    ListField scrolling behind other fields

    So no, you're not crazy, and no, you do not have something wrong.  I hope it's a consolation

  • trying to capture press ENTER or wheel on listfield

    Hey,.

    I have a ListField and a BasicEditField on the same screen. After the substitution of such methods below that Yes, other than the ENTRANCE keys do seem to do not produce all the actions. someone help me on this please? I want to capture enter and wheel press right on the listfield, so that I can use it as a typical menu.

    Thank you

    protected boolean navigationClick(int status, int time) {
        System.out.println("wheel pressed");
        return true;
    }
    
    protected boolean keyChar(char key, int status, int time) {
        boolean retVal = false;
    
        if(key == Characters.ENTER){
            System.out.println("pressed enter");
            retVal = true;
        }
    
        return retVal;
    }
    

    Re trackwheelclick/navigationclick, see this thread:

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

    To substitute, either extend the class and create your own ListField or use an inner class as follows:

    ListField mylistField = new ListField() {
        protected boolean keyChar(char key, int status, int time) {
            // your code here
        }
    };
    
  • 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.

  • 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