Vector to ListField

Hello friends,

I vector with 2 items (strings) in there, I want to add ListField, so that I can pass the string which top and change its color in the listbox. Can anyone help me please with simple code. I try to draw, but I think I'm missing something.

I searched the net and compared from my code but .

Clicking a ListField won't actually change, for what is expected.  Instead, substitute the navigationClick and/or methods keyChar to capture a click trackpad / key press (for example, the Enter key).

Tags: BlackBerry Developers

Similar Questions

  • ListField (s) nested in VerticalFieldManager-> SWIPE/SCROLL with HorizontalFieldManager

    I have 2 ListField objects. Each within its own VerticalFieldManager object. 2 VFMs are inside a HorizontalFieldManager object. I am trying to allow the user to BLOW/scrolling of one ListField to another (LEFT/RIGHT). I did not have the TouchEvent portion this again (I guess I'll have to put in place something there).

    Here's what I have so far... However, only the first ListField shows with data (random numbers right now). The other is empty. I also want to allow the user to select individual lines in each ListField

    All the suggestions/help is appreciated.

    See you soon,.

    public final class MyScreen extends MainScreen {
    
        public MyScreen() {
            super(MyScreen.NO_VERTICAL_SCROLL);
            Random rand = new Random();
            HorizontalFieldManager hm = new HorizontalFieldManager(HorizontalFieldManager.HORIZONTAL_SCROLL);
            Vector v1 = new Vector();
            Vector v2 = new Vector();
            for (int i = 0; i < 10; i++) {
                v1.addElement(Integer.toString(rand.nextInt(200)));
                v2.addElement(Integer.toString(rand.nextInt(300)));
            }
            hm.add(new ListManager(v1, "VM lf1"));
            hm.add(new ListManager(v2, "VM lf2"));
            add(hm);
    
            // Set the displayed title of the screen
            setTitle("MyTitle");
    
        }
    
        class ListManager extends VerticalFieldManager {
            private Vector _elements;
            ListField _lf;
    
            ListManager(Vector elements, String title) {
                super(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
                _lf = new ListField();
                _lf.setCallback(new ListCallback());
                this._elements = elements;
                add(new RichTextField(title));
                add(_lf);
                updateList();
            }
    
            private class ListCallback implements ListFieldCallback {
    
                public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
                    g.setColor(Color.BLACK);
                    String text = (String) _elements.elementAt(index);
                    g.drawText(text, 5, y, 0, w);
                }
    
                public Object get(ListField list, int index) {
                    return _elements.elementAt(index);
                }
    
                public int indexOfList(ListField list, String p, int s) {
                    return _elements.indexOf(p, s);
                }
    
                public int getPreferredWidth(ListField list) {
                    return Display.getWidth();
                }
            }
    
            protected void sublayout(int width, int height) {
                super.sublayout(width, height);
    
                setExtent(width, height);
            }
    
            private void updateList() {
                _lf.setSize(_elements.size());
            }
    
        }
    }
    

    The two lists show up... However, the halves just in the same HM. My goal is to have everyone take full screen (visible at the time) only... then the user has to SWIPE (from EAST to WEST) to see the list of the other.

    So I changed the following line

    super.sublayout(Display.getWidth(), height);
    

    Thanks Peter

  • 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);
        }
    
    }
    
  • Unable to fill ListView with vector

    I'm using a sample I got on the internet to create a listfield

    that contains an image and the data contained in a vector.

    Data are obtained from a JSON array that is created from a script php accessing a mysql database.

    The problem is that the listfield poster not only any content, even if there are items in the table.

    This is the code I use to get the JSON array data :

    JSONArray items_array=job.getJSONArray("items");
                        for(int i=0;i
    

    The code for the ListFieldCallback:

    class MyListModel implements ListFieldCallback
           {
    
               private ListField _view;
               private int _defaultRowHeight=32;
               private int _defaultRowWidth=_defaultRowHeight;
               private int _txtImagePadding=5;
               private Bitmap _bitmap;
                private Vector _data;
               public MyListModel(ListField list,Vector data)
                     {
                         _view=new ListField();
                        _data=new Vector();
                         _data=MyScreen.data_vec;
                         _view=list;
                         list.setCallback(this);
                        // _view.setSize(_data.size());
                         _view.setRowHeight(_defaultRowHeight);
                         _bitmap=null;
    
                         //list.setSize(_data.size());                     
    
                         }
    
               public void drawListRow(ListField list,Graphics g,int index,int y,int w)
               {
                   Items itemToDraw=(Items)this.get(list,index);
                   String name=itemToDraw.getName();
                   g.drawText(name,_defaultRowWidth+_txtImagePadding,y,DrawStyle.LEADING|DrawStyle.ELLIPSIS,w-_defaultRowWidth-_txtImagePadding);
    
                   g.drawBitmap(0,y,_bitmap.getWidth(),_bitmap.getHeight(),_bitmap,0,0);
    
                   }
    

    The code for the method of success which must now fill listview:

    public void success(final Vector listboys)
            { 
    
              UiApplication.getApplication().invokeLater(new Runnable()
              {public void run()
              {
                 data_vec=new Vector();
              data_vec=listboys;
              Items it1=(Items)data_vec.elementAt(0);
              error("Vector Main Screen " +it1.getName());
                                 final MyListField myListView=new MyListField();
          final  MyListModel myListModel=new MyListModel(myListView,data_vec);
         myListView.addToContextMenu(myListModel.getAddMenuItem(0,0));
        myListView.addToContextMenu(myListModel.getRemoveMenuItem(0,0));
        myListView.addToContextMenu(myListModel.getModifyMenuItem(0,0));
        myListView.addToContextMenu(myListModel.getEraseMenuItem(0,0));
    
        {
            Manager vfm=getMainManager();
            vfm.add(myListView);
            vfm.add(new SeparatorField(SeparatorField.LINE_HORIZONTAL));
            setTitle("List Demo Title");
    
            }
    

    The listview is always empty. I don't see where data is passed to display. Whenever I call:

    list.setSize(_data.size());
    

    I always get a null pointer exception. How can I get the listview to display the data contained in the vector itemsholder. Thank you

    using images in a listfield is not difficult, to improve that worked for you.

    You can use drawBitmap to draw the image in the listfield.

  • 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...

  • 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);
    }

  • Help me to solve this problem in listfield

    How to add a space between two listfied. ?

    How to do a listfield to another by using the alt key?

    package com.black.applicationloader;

    import java.util.Vector;

    Import net.rim.device.api.system.Display;
    Import net.rim.device.api.ui.Color;
    Import net.rim.device.api.ui.Font;
    Import net.rim.device.api.ui.Graphics;
    Import net.rim.device.api.ui.Manager;
    Import net.rim.device.api.ui.XYRect;
    Import net.rim.device.api.ui.component.ListField;
    Import net.rim.device.api.ui.component.ListFieldCallback;
    Import net.rim.device.api.ui.container.VerticalFieldManager;

    import com.black.blackinterface.BlackInterface;
    import com.black.common.BaseScreen;
    import com.black.components.CustomEditField;
    import com.black.utility.Utilities;

    SerializableAttribute public class BlackSecondScreen extends BaseScreen implements BlackInterface, ListFieldCallback {}
    Private VerticalFieldManager listFieldManager;
    Private VerticalFieldManager listFieldManager_2;
    private static final String [] _elements is {"First element" "Second element", "Third element", 'Fourth element', 'Fifth element'};.
    private vector _listElements = new Vector (_elements.length, 1);
    columnWidth int = Display.getWidth () / 4;
    Private boolean hasFocus; = false
    Private CustomEditField userEditField;
    ListField colourList_1;
    ListField colourList_2;

    {BlackSecondScreen()}

    colourList_1 = new ListField() {}

    protected void drawFocus (Graphics graphics, boolean on) {}
    XYRect rect = new XYRect();
    graphics.setGlobalAlpha (200);
    getFocusRect (rect);
    drawHighlightRegion (graphics, HIGHLIGHT_FOCUS, true, rect.x, rect.y, rect.width, rect.height);
    }

    {} public void onFocus (int direction)
    hasFocus = true;
    super.onFocus (branch);
    }

    Called when a field loses focus.
    public void onUnfocus() {}
    hasFocus = false;
    super.onUnfocus ();
    Invalidate();
    }

    public int moveFocus (amount int, int status, time int) {}
    Invalidate (getSelectedIndex ());
    Return super.moveFocus (amount, status, time);
    }
    };

    colourList_1.setCallback (this);
    int elemWidth = _elements.length;
    for (int count = 0; count)< elementlength;="">
    {
    colourList_1.insert (count);
    This.Insert (_elements [count], count);
    }

    colourList_2 = new ListField() {}

    protected void drawFocus (Graphics graphics, boolean on) {}
    XYRect rect = new XYRect();
    graphics.setGlobalAlpha (200);
    getFocusRect (rect);
    drawHighlightRegion (graphics, HIGHLIGHT_FOCUS, true, rect.x, rect.y, rect.width, rect.height);
    }

    {} public void onFocus (int direction)
    hasFocus = true;
    super.onFocus (branch);
    }

    Called when a field loses focus.
    public void onUnfocus() {}
    hasFocus = false;
    super.onUnfocus ();
    Invalidate();
    }

    public int moveFocus (amount int, int status, time int) {}
    Invalidate (getSelectedIndex ());
    Return super.moveFocus (amount, status, time);
    }
    };

    colourList_2.setCallback (this);

    for (int count = 0; count)< elementlength;="">
    {
    colourList_2.insert (count);
    This.Insert (_elements [count], count);
    }

    Add (colourList);
    createComponents();
    layoutComponents();

    }

    public void createComponents() {}

    listFieldManager = new VerticalFieldManager (Manager.VERTICAL_SCROLL |) Manager.HORIZONTAL_SCROLL) {}
    protected void sublayout (int maxWidth, maxHeight int) {}
    Super.sublayout (maxWidth, 2 * colourList_1.getRowHeight ());
    setExtent (maxWidth, 2 * colourList_1.getRowHeight ());

    };

    };

    listFieldManager_2 = new VerticalFieldManager (Manager.VERTICAL_SCROLL |) Manager.HORIZONTAL_SCROLL) {}
    protected void sublayout (int maxWidth, maxHeight int) {}
    Super.sublayout (maxWidth, 2 * colourList_2.getRowHeight ());
    setExtent (maxWidth, 2 * colourList_2.getRowHeight ());

    };

    };

    userEditField = new CustomEditField (Utilities.getAdjustedWidth (150))
    Utilities.getAdjustWidth (2), Manager.NO_HORIZONTAL_SCROLL
    // | (Manager.VERTICAL_SCROLL, true);

    }

    public void layoutComponents() {}
    TODO self-generating method stub
    listFieldManager.add (colourList_1);

    listFieldManager_2.add (colourList_2);
    Add (listFieldManager);
    Add (listFieldManager_2);

    }

    public void initializeListeners() {}
    TODO self-generating method stub

    }

    public void setComponentsXYMargins() {}
    TODO self-generating method stub

    }

    ' Public Sub drawListRow (ListField listField, graphics graphics, int index,
    int y, int width) {}
    int curSelected;
    If (hasFocus) {}
    curSelected = listField.getSelectedIndex ();
    } else {}
    curSelected = - 1;
    }
    If (index %2 == 0) {}
    graphics.setColor (Color.PERU);
    graphics.fillRect (0, y, width, listField.getRowHeight ());
    } else {}
    graphics.setColor (Color.WHEAT);
    graphics.fillRect (0, y, width, listField.getRowHeight ());
    }
    graphics.fillRect (0,0,width,y);

    int xPos = 0; int ypos = 0;
    graphics.setFont (Font.getDefault ()); / / Please set a value of fonts
    It is the first text of the column
    graphics.setColor (Color.BLACK);
    graphics.drawText("column1"+index,xpos,y);
    XPos += columnWidth;

    graphics.setColor (Color.RED);
    graphics.drawText("column2",xpos,y);

    XPos += columnWidth;
    graphics.drawText("column3",xpos,y);

    XPos += columnWidth;

    graphics.drawText("column4",xpos,y);

    }

    public Object get (ListField listField, int index) {}
    TODO self-generating method stub
    Return _listElements.elementAt (index);
    }

    public int getPreferredWidth (ListField listField) {}
    TODO self-generating method stub
    Return Graphics.getScreenWidth ();
    }

    public int indexOfList (String prefix, int start, ListField listField) {}
    TODO self-generating method stub
    Return _listElements.indexOf (prefix, start);
    }

    public final void insert (String toInsert, int index)
    {
    _listElements.insertElementAt (toInsert, index);
    }

    public void erase()
    {
    _listElements.removeAllElements ();
    }

    }

    Hello

    Not able to understant it please explain...

  • Download the text of ListField

    After hours of sifting through forums and Googling I hope someone can help me.

    I have a ListField filled with a vector of strings. The strings are the urls that the user can select to load a page. I'm trying to get the selected url, but when I click on one has no effect, it always loads the first element.

    It doesn't seem to be any code that loads the URL here.  It seems unlikely that this bug is in this code.

    When I did click ListFields I use

    . getSelectedIndex()

    to see how input from the user has selected in fact.

  • Sort of a listfield

    Hello..

    I display a listfield of names in the address book...

    I use vector for holding data from address book...

    Vector objects contains the following data...

    Title

    First name

    Family name

    Contact No.

    I'm adding contacts to the listfield. but I want that they sorted according to the displayname property that contains the title, first name and family name...

    Please suggest...

    Thank you

    He provided no method of sorting a ListField.

    You can sort the vector yourself or use one of the classes that can be sorted.

    Generally, I sort myself, that you can then give your users the ability to change the type - for example, you might want to sort your vector by the first or last name.

    When sorting of the channels, I recommend that the String.compareTo (.) or StringUtilities.compareToIgnoreCase (.)

  • 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 line personalized with text and images

    Hello

    I use the example of complex files provided at this URL as a basis for my application. I want to do is get data feed from a Web site and post it in a ListField. Each row in the field has a picture and associated text.

    I made the following changes in my implementation of the application in the example

    1. create a normal ListField instead of a subclass of ListField

    2 getting data from the stream and fill a vector with the necessary information

    3. implementation of the ListFieldCallback.

    In the drawListRow of the callback method, I create a TableRowManager object and pass the data for that particular line. Using these data, I create fields and adding them to the TableRowManager. Then by the drawRow of the TableRowManager method, I call sublayout() and specifying the x, y, width, height for each field in the TableRowManager.

    Now, when you debug the application, I see that the drawListRow method is called whenever I move around the list or when the ListField is first added to its parent. But none of the fields or lines are displayed.

    DrawRow even is called whenever drawListRow. But the lines are never displayed. I just get a white screen. Tried to remove all fields and keep a single LabelField, but even that is not displayed.

    Here's the code, if this is useful

    Class TableRowManager

    private class TableRowManager extends Manager
        {
            int _index;
    
            TableRowManager(String myTxt, String msg, String imageUrl, int index)
            {
                super(0);
                BitmapField imgField = new WebBitmapField(imageUrl);
                add(imgField);
    
                LabelField personLabel = new LabelField(myTxt, DrawStyle.ELLIPSIS);
                add (personLabel);
    
                LabelField itemLabel = new LabelField(msg, DrawStyle.ELLIPSIS);
                add(itemLabel);
    
                _index = index;
            }
            public void drawRow(Graphics g, int x, int y, int width, int height)
            {
                layout(width, height);
                setPosition(x, y);
                g.pushRegion(getExtent());
                g.popContext();
            }
            protected void sublayout(int width, int height)
            {
                Field currField1 = getField(0);
                layoutChild(currField1, getPreferredWidth(), getPreferredHeight());
                setPositionChild(currField1,0,0);
                Field currField2 = getField(1);
                layoutChild(currField2, (int) Field.USE_ALL_WIDTH, getPreferredHeight());
    
                setPositionChild(currField2,40,80);
    
                Field currField3 = getField(2);
                layoutChild(currField3, (int) Field.USE_ALL_WIDTH, getPreferredHeight());
                setPositionChild(currField3,40,120);
    
                setExtent(getPreferredWidth(), getPreferredHeight());
            }
            public int getPreferredWidth()
            {
                return Display.getWidth();
            }
            public int getPreferredHeight()
            {
                return 150;
                //return height of row
            }
        }
    

    the callback method drawListRow

    public void drawListRow(ListField list, Graphics g, int index, int y, int w)
        {
            String text = (String)listElements.elementAt(index);
            String str1 = text.substring(0,text.indexOf("-"));
            String str2 = text.substring(text.indexOf("-")+2);
            String imageName = image[index];
           String url = "http://myURL/"+imageName;
           TableRowManager rowManager = new TableRowManager(str1,str2,url, index);
            rowManager.drawRow(g, 0, y, w, list.getRowHeight());
        }
    

    Can someone please help me with this. The format of what I'm looking for is something like this

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

    | image |  LabelField1

    |           |  LabelField2

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

    Thank you.

    What I usually do with the listField is myself to draw the bitmap and text, something like the following:

    ' public void drawListRow (list ListField, Graphics g, int index, int y, int w)
    {
    String text = (String) listElements.elementAt (index);
    String str1 = text.substring (0, text.indexOf("-"));
    String str2 = text.substring (text.indexOf("-") + 2);
    String imageName = image [index];

    Z.i. bitmap = / * get the bitmap * / (better preparation before coming here, for performance)

    int xPos = LEFT_OFFSET;
    int ypos = TOP_OFFSET + y;
    int w = bitm.getWidth ();
    int h = bitm.getHeight ();
    fontHeight int = this.getFont () .getHeight ();

    g.drawBitmap (PosX, Posy, w, h, z.i., 0, 0);

    PosX = w + SOME_OFFSET

    graphics.drawText (str1, xpos, ypos);
    YPos += fontHeight;

    graphics.drawText (str2, xpos, ypos);

    }

    It worked for me all the time.

    Of course, I don't want to say that do you it this way, but I'm just give another alternative that works.

    Rab

  • The remote XML parsing and ListField implementation

    I use Blackberry 9800 Simulator, JRE 6.0.0

    Hello

    I have a remote XML I want to analyze, but for some reason, my ListField shows only 1 row. I tried debugging and saw the number of attributes my vector, which is significantly greater than 1.

    Here is my code: http://pastebin.com/zRDW2xfn

    I'm doing something wrong?

    In addition, in the ListFieldCallback, the drawListRow index does not increment...

    Hey there,

    I found the problem, if you print the exception, you will see what is wrong. Basically, you dodnt have access to the UI within this thread.

    I changed the class connectionthread for you below.

    private class Connection extends Thread{
    
            public String title;
            public int i=0;
    
            public Connection(){
                super();
            }
    
            public void run(){
                // define variables later used for parsing
                Document doc;
                StreamConnection conn;
                try{
                    conn = (StreamConnection)Connector.open("http://tpae.me/events.xml;deviceside=true");
                    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                    docBuilder.isValidating();
                    doc = docBuilder.parse(conn.openInputStream());
                    doc.getDocumentElement().normalize();
                    NodeList list = doc.getElementsByTagName("Event");
    
                    for (i=0;i
    

    Note: the fix is not optimal, but his show you how it should be done.

    Please let me know if you still have problems or questions.

  • 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);
    }

    }

  • How to udpate listfield lines specially

    This app, I have developed is a reader of history. It has a screen which contained a listfield. I hope that I can update the listfield.

    Maybe just change a line of the listfield with special index.

    But I do not know how to implement it.

    Now I just use the method as follows:

    for (int i = 0; i)<>

    {

    ListField.Delete (0);

    listfieldcallback. Remove (0);

    }

    for (int i = 0; i = Vecotr.Size (); i ++)

    {

    ListField.Insert (i);

    listfieldcallback. Insert (Object, i);

    }

    then call this Manager listfield: listfieldmanager.invalidate ();

    I think that there should be better elsewhere update lines specially listfield

    In your ListFieldCall back when you insert the new element, he might just added to the vector, just give a look at the methods you use.  You may need to use Vector.insertElementAt ()...

  • Java Blackberry ListField

    I developed an Rss Application for Blackberry (java) and I've posted titles successfully (list of Radio stations must play online) from code Rss File.i already developed to play these list of Radio channels, but my requirement is to play the first channel (the first list) when my list initially displayed (list of strings) , can someone help me where I can write my logic (the first string of default playback) to run after my displayed immediately channels?

    Here my code for Rss:

    SerializableAttribute public class RssScreen extends ListFieldCallback implements screen, FieldChangeListener {}
    Connection _connectionthread;
    private static ListField _list;
    Image of the chain;
    String title;
    private static Vector listElements is new Vector();.
    private static Vector listImage is new Vector();.

    public long mycolor;
    MainManager VerticalFieldManager;
    VerticalFieldManager subManager;
    int selectedList;
    Radio radio;

    public RssScreen() {}
    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);
    }
    };

    Add (mainManager);

    _list = new ListField()

    {
    protected boolean navigationClick (int status, int time)
    {
    Returns true;
    }
    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();
    }

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

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

    Conn = (StreamConnection) Connector.open ("http://toucheradio.com/toneradio/android/toriLite/toriplaylist.xml" + "; deviceside = true");

    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 ();
    NodeList listImg = doc.getElementsByTagName ("title");
    for (int i = 0; i)< listimg.getlength();="" i++)="">
    Node node = listImg.item (i) .getFirstChild ();
    listElements.addElement (textNode.getNodeValue ());
    image = textNode.getNodeValue ();
    }
    List of NodeList = doc.getElementsByTagName ("image");
    for (int a = 0;< list.getlength();="" a++)="">
    Node textNode1 = list.item (a) .getFirstChild ();
    listImage.addElement (textNode1.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);

    Invalidate();
    }
    });
    }

    }

    ' public void drawListRow (list ListField, Graphics g, int index, int y, int w)
    {
    String title = (String) listElements.elementAt (index);
    Image = (String) listImage.elementAt (index) string.
    Bitmap image1 = getBitmapFromUrl (image);

    System.out.println ("title" + title);
    System.out.println ("image" + image);
    int yPos = 0 + y;
    g.drawLine (0, yPos, w, yPos);

    g.drawText (title, 0, y, 0, w);
    g.drawBitmap (0, image1.getWidth (), image1.getHeight (), image1, 0, 0);

    }

    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) {}

    }

    }

    you view the list for help
    subManager.add (_list);
    After this line, you can call play (listElements.elementAt (0)).

Maybe you are looking for