Scrolling ListField

I read many more posts scrolling ListField and they helped me to get that much, but now I'm stuck.  I have my list field in a VerticalManager with scroll work.  I set it up so that there are 5 visible rows in the ListField.  However, when I scroll down past the last visible line (there is currently a total of 9 lines of the list), paint lines is no longer the text of the line.  I developed a custom implementation ListField, who has a foreground and background color.  The idea is that each line is focused, switch foreground and background of color - the selected line a deep Navy with white text and unselected lines have a white background with marine text.  Works very well for the visible rows, but when I scroll beyond rank 5 to reveal the invisible lines, they just paint with the Navy background and white text.  Here's my class of custom list field (which was based on something that I found on a forum or in the knowledge base):

Import net.rim.device.api.ui.Graphics;
Import net.rim.device.api.ui.XYRect;
Import net.rim.device.api.ui.component.ListField;

SerializableAttribute public class ColoredListField extends ListField
{
Private boolean hasFocus = false;
Private final int fixedWidth;
private int fgcolor;
private int bgcolor;
Private final int fixedHeight;

public ColoredListField (int width, int height, int fgcolor, bgcolor int)
{
this.fixedWidth = width;
this.fixedHeight = height;
This.fgColor = fgcolor;
This.BgColor = bgcolor;
}

public int getPreferredWidth()
{
return fixedWidth;
}

public void layout (int width, int height)
{
setExtent (fixedWidth, fixedHeight);
}

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

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

Public Sub onUnfocus()
{
hasFocus = false;
super.onUnfocus ();
Invalidate();
}

public void paint (Graphics graphics)
{
Get current cutting zone because it will be the only party which
need to repaint
XYRect redrawRect = graphics.getClippingRect ();
If (redrawRect.y<>
throw IllegalStateException (new)
' The variable 'y' clipping ' +.
"rectangle is.< 0:="" "="" +="">

If the ListField has focus determine the selected line.
rowHeight = getRowHeight() int;
int currEntry = redrawRect.y / rowHeight.
int lastVisibleEntry = (redrawRect.y + redrawRect.height - 1) / rowHeight.
lastVisibleEntry = Math.min (lastVisibleEntry, getSize() - 1);
int y = currEntry * rowHeight.

int curSelected = hasFocus? getSelectedIndex():-1;
Draw each line
for (; currEntry<= lastvisibleentry;="">
{
graphics.setColor (currEntry == curSelected? bgcolor: fgcolor);
graphics.fillRect (0, y, redrawRect.width, rowHeight);
graphics.setColor (currEntry == curSelected? fgcolor: bgcolor);
graphics.drawText (getCallback () .get (this, currEntry) m:System.NET.SocketAddress.ToString (), 0,)
y);
Assign new values for the y-axis move a row downwards.
y += rowHeight.
}
}
}

Here's how I instantiated class:

private int screenW = Graphics.getScreenWidth ();
private int screenH = Graphics.getScreenHeight ();
private int listWidth = (int) (screenW * 0.95);
private int listHeight = (int) (screenH * 0.4).
private ColoredListField myListField = new ColoredListField)
listWidth, listHeight, selectedFGColor, selectedBGColor);

Also, here is my point:

private static class DiaryEntryListCallback implements ListFieldCallback
{
private DiaryEntry [diaryEntryList];

public DiaryEntryListCallback() throws Exception
{
diaryEntryList new = DiaryEntry [0];
init();
}

public void init() bird Exception
{
DiaryEntry [] tmpDiaryEntryList =
DiaryDAO.instance () .getDiaryEntriesAsArray (true);
If (tmpDiaryEntryList! = null & tmpDiaryEntryList.length > 0)
diaryEntryList = tmpDiaryEntryList;
on the other
{
diaryEntryList = new DiaryEntry [1];
diaryEntryList [0] = new DiaryEntry ("No data",
Calendar.getInstance ());
}
}

public void init (DiaryEntry [diaryEntries]) throws exceptions
{
diaryEntryList = diaryEntries;
}

public int getNumberOfRows()
{
Return diaryEntryList.length;
}

' Public Sub drawListRow (ListField l, Graphics g, int index, int y, int w)
{
draw text is managed by the implementation of the custom list field
}

public {get {Object (ListField listField, int index)
{
return diaryEntryList [index];
}

public int getPreferredWidth (ListField listField)
{
Return listField.getPreferredWidth ();
}

public int indexOfList (String prefix, ListField listField, int start)
{
int size = diaryEntryList.length;
for (int i = 0; i)< size;="">
{
DiaryEntry currEntry = diaryEntryList (DiaryEntry) [i];
If (currEntry.getEntryText () .toLowerCase () .startsWith)
(prefix.toLowerCase ()))
Return i;
}
Return listField.getSelectedIndex ();
}
}

And here's where I build the main screen, adding the list field and other areas:

Private Sub createMainScreen()
{
mainMgr = new ColoredVerticalManager (selectedBGColor,
Manager.USE_ALL_HEIGHT);
listMgr = new ColoredVerticalManager)
selectedBGColor,
Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
mainMgr.add (diaryEntriesLabel = new FixedWidthLabelField)
"' Diary entries:»(, listWidth,-1, selectedFGColor, selectedBGColor));"
Try
{
listCallback = new DiaryEntryListCallback();
diaryEntriesListField.setSize (listCallback.getNumberOfRows ());
diaryEntriesListField.setCallback (listCallback);
diaryEntriesListField.setFocusListener (new DiaryFocusListener());
listMgr.add (diaryEntriesListField);
mainMgr.add (listMgr);
}
catch (System.Exception e)
{
Dialog.Alert ("error when loading of list one diary entry:" + e.getMessage ());
}
mainMgr.add (selectedEntryLabel = new FixedWidthLabelField)
((' Selected: input: ",-1, -1, selectedFGColor, selectedBGColor));
mainMgr.add (diaryEntry);
Add (mainMgr);
}

Clues as to why when scrolling past the visible lines, he stops painting?

Thank you

Steve

Hello

You want listfield fixed size with active scroll.

Please try the following solution:

Removed listfield class the following function:

public void layout (int width, int height)
{
setExtent (fixedWidth, fixedHeight);
}

That you override the trace of the listfield, the measure will be defined as a fixed height. Therefore, you have noticed that Manager of vertical field scrolls but listfield not scroll.

Please override method 'sublayout' of vertical field Manager "listmgr":
VerticalFieldManager oVerticalFieldManager = new VerticalFieldManager (MainScreen.VERTICAL_SCROLL |) MainScreen.VERTICAL_SCROLLBAR)
{
public int getPreferredHeight()
{
Return nFixedHeight;
}
           
Rewritten to define the visible height for the vertical field Manager.
protected void sublayout (int width, int height)
{
height = nFixedHeight;
Super.sublayout (width, height);
setExtent (width, height);
}
};

This code works for me fine.

Kind regards
Shubhangi

Tags: BlackBerry Developers

Similar Questions

  • Limit scrolling ListField

    I have two screens with same ListField code.

    When the ListField gets Focus, it selects the last item in the list. Then you can scroll vertically. When you scroll over the bottom buttons to resume the focus at the bottom of the screen.

    On one screen, it works perfectly. When you scroll to the top, he remains on the first point. When you scroll down, it scrolls down and buttons to resume the focus.

    On the other hand (using the same code), it scrolls on the top of the list and loses focus. When you scroll to the bottom, he returned to focus on the last item in the list.

    How can I prevent the ListField loses focus when you scroll past top?

    I fought it for a while. Any help will be appreciated.

    The code is very basic and as follows:

    logList = new ListField(){
        public void onFocus(int direction) {
            setSelectedIndex(this.getSize());
        }
        public boolean keyChar( char key, int status, int time ) {
            return false;
        }
    };
    ListCallback _callback = new ListCallback();
    logList.setCallback((ListFieldCallback) _callback);
    logList.setFont(fontLog);
    logList.setRowHeight(fontLog.getHeight()); 
    
    ...
    
    fmLog   = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL);
    fmLog.add(logList);
    mainManager.add(fmLog);
    
    ...
    
    private void reloadList() {
        logList.setSize(logListElements.size());
        fmLog.setVerticalScroll(Math.max(0, fmLog.getVirtualHeight() - fmLog.getVisibleHeight()));
    }
    
    ...
    
    public class ListCallback implements ListFieldCallback  {
        private int listWidth;
    
        public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
            ...
        }
        public Object get(ListField list, int index) {
            return logListElements.elementAt(index);
        }
        public int indexOfList(ListField list, String prefix, int string) {
            return logListElements.indexOf(prefix, string);
        }
        public int getPreferredWidth(ListField list) {
            return displayWidth;
        }
    }
    

    ! @# $ NullField()...

    You never see these things until after the question...

  • ListField Scrolling - please help!

    I have read many comments scrolling ListField and I have

    a hard time!

    Trying to get the scroll for a ListField. It is in a VerticalFieldManager.

    The ListField is the contents of a table like structure. The BitmapFields

    on the left you see below, are a different Manager.

    The manager that contains a scrolling VerticalFieldManager

    and scroll to the WIDE bars.

    Start photo:

    NOTE the arrow the down scroll bar here, no arrow (?). But I'm at the top of the list, I want to scroll to the top to see the bottom. There are 30 entries in this list. This is a problem.

    After scrolling:

    I do not understand why scrolling results in the image above.

    Where is my top scroll bar arrow?

    In addition, after scrolling once, I lose the arrow of the scroll bar.

    Ideas?

    Here's the drawRow in my ListView:

    I realized what was going on.

    Field.getExtent () does not return a copy of the rectangle of the measurement field - but the rectangle extent itself.

    So, if you have

    XYRect r = this.getExtent ();

    r.x += factor;

    Then your field will be repainted in the wrong place. It will be a wrong x.

    I think it is a bug or bad design, because this measure rectangle should be wrapped.

    You cannot modify it via the interface of the method, you should not be able to change this way.

    getExtent() should return a copy of this rectangle, in my opinion.

    So I was something with measurement values, calculation without realizing that I was changing the coordinates of the field.

    My ListField wasn't all scrolling. It has simply been moved downwards.

    Unfortunately, it still does not scroll.

    lucidbee.

  • ListField scroll jumps in OS 6

    Has anyone noticed that scrolling ListField tends to jump around in an unexpected way in OS6? It looks good in all the other versions.

    Any ideas?

    I thought about it. It had to do with the focus on the last item layout to force scrolling to the bottom of the list. OS6 didn't like it...

    I changed it to:

    private void reloadList() {
            logList.setSize(MyApplication.logListElements.size());
            fmLog.setVerticalScroll(Math.max(0, fmLog.getVirtualHeight() - fmLog.getVisibleHeight()));
    }
    
  • ListField: why complexity?

    Hello everyone.

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

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

    I tried a bunch of things:

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

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

    ANY help would be appreciated!  Thanks in advance guys!

    -paul

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

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

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

    Give it a go and let us know.

  • ListField setListSelection() problem of drawing

    Hi all, I'm new in the development of bb and I will try to create a ListField class to manage ListField and ListFieldCallBack design, but I have a problem with ListField SetSelectedIndex (Position), because ListFieldCallBack does not "drawListRow" (don't shoot list lines) and ListField seems to be empty, it restarts to draw only when users scroll ListField control.
    I don't really know how to resolve or work around this problem...
    I try with RIM Jde 5.0.0 and BB Storm 9550

    Application - start
    Grid VediOrdini = new Grid();
    VediOrdini.Inizialize ("Select CodCli, CodLinea, coding of AgeLinea", Gv.Db, this);
    VediOrdini.AddColumnPerc (0, "CodCli", "L", 40);
    VediOrdini.AddColumnPerc (1, "CodLinea", 30, "C");
    VediOrdini.AddColumnPerc (2, "Coding", 30, "R");
    VediOrdini.Draw ();
    VediOrdini.SetSelectedIndex (350);

    -Draw() class ListField
    MiaLista = new ListField(); Lista oggetto Dichiaro
    MiaLista.setRowHeight (RowHeight); Transamissões is delle lines
    MiaCallBack = new TestListCallback(); Reminder it derivo by manage the list
    MiaLista.setCallback (MiaCallBack); E lo transamissões sulla mia lista
    RowSelected = - 1; Inizializzo he number di riga per poterlo manage poi selezionata e tornare in caso di GetSelectedIdex
    Line r;
    int i = 0;
    {while (DataReader.Next ())}
    r = DataReader.getRow (); Ciclo he mio "DataReader".
    MiaLista.insert (i); Will di volta in volta una riga alla lista
    By mi ogni Riga del datareader i campi della riga in one Salvo ' oggetto line
    Lines MiaRiga = New Rows (Colonna.size (), r);
    Riga.addElement (MiaRiga);

    i ++ ;
    }
    MyVFieldManager VFieldManager = new MyVFieldManager (Manager.VERTICAL_SCROLL, ListWidth, ListHeight);
    VFieldManager.add (MiaLista); Gli bell'attacco E degli articles list
    SC. Add (VFieldManager); Lo will went form

    -SetSelectedIndex (Posizione) class ListField
    MiaLista.setFocus ();
    MiaLista.setSelectedIndex (Posizione);
    Manager manager = MiaLista.getManager ();
    manager.setVerticalScroll (Posizione * RowHeight);
    MiaLista.invalidateRange (Posizione, (Posizione + RowPage));

    Can someone help me please?
    Thanks in advance

    I've seen problems such as too, where the setSelectedIndex must run on the event Thread.

    The best thing to do is some code to be run in this way and use "invokeLater" package.  I actually do sometimes even when I'm on the edge of events, because I want to change to take place later.

    Then put the setSelectedIndex and everything you think you need to do, in one of them:

    UiApplication.getUiApplication () .invokeLater (new Runnable() {}

    public void run() {}

    here

    {

    {);

  • How to display the scroll bar on the listField

    I use the following code to add a listField to VerticalManager, but he couldn't display a vertical scroll bar.

    Thanks for any help.

    Michael

    SerializableAttribute public class ContactsListField extends VerticalFieldManager
    {

    .......

    public ContactsListField (int width, int height, string keyword)
    {
    Super(Manager.NO_VERTICAL_SCROLL |) Manager.FIELD_HCENTER);
            
    managerWidth = width;
    managerHeight = height;
    VerticalFieldManager vor = new VerticalFieldManager(Manager.VERTICAL_SCROLL |)
    Manager.VERTICAL_SCROLLBAR | Manager.FIELD_HCENTER | Manager.FIELD_VCENTER);
            
    listField = new ListField(0,ListField.FOCUSABLE)
    {
    public void paint (Graphics g)
    {
    getManager () .invalidate ();
    Super.Paint (g);
    }
    };
            
    listCallback = new ListCallback();
    listField.setCallback (listCallback);
            
    contacts = getData();
    If (contacts! = null)
    filterKeyword (keyword);
                        
    VFM. Add (ListField);
    Add (VFM);
    }

    Hmm... nothing extraordinary.  One might want to draw focus in the ListField by defining a suitable background and foreground colors, but still - there is nothing that would prevent the drawing of the ScrollBar by the Manager.  Of course, Manager.FIELD_VCENTER is not used in the optimization of resources, and I suspect that FIELD_HCENTER will be useless too (I think ListField uses all of the default width).  You can delete these two style bits.

    One thing to check - what can you add that ContactListField to?  If it's a screen or a derived class, you must use NO_VERTICAL_SCROLL in the constructor.  In this way, you will ensure that is vfm that manages the painting "scrollbar".

  • 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

  • ListField in image sets without scrolling Page

    What I'm trying to do, it's like what Poynt done with their results, where the ListField scrolls, but around it stays the same. All I have is a listfield on a screen, but I have a bitmap as a background and would like to keep it fixed while only the listfield scrolls

    Someone has an idea how Poynt did it?

    Hello

    Take a look at this thread

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

  • ListField (s) nested in VerticalFieldManager-&gt; 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

  • ListField does not scroll in the storm

    Hello

    I use the simulator of the storm.

    I have a ListField inside a VerticalFieldManager in a VERTICAL_SCROLL and VERTICAL_SCROLLBAR style.

    I can move the list down with keyboard arrows down or the field list does not scroll to the top, but when I try to use the key (right key) in the Simulator.

    Looks like I'm missing something, please help.

    Thank you

    Thanks for the help.  But I thought about it.  Missed me the call to the call of super.touchEvent (event)...  So now, I handle the case else if is not a click, then I call the return super.touchEvent (event);

  • Cannot get the scroll bars to view on popupscreen listField

    Hello world.

    I'm developing a popup for the 9530 screen application that has only a listField on the pop-up screen. However, I do not

    the scroll bars on my listField. Here is a snippet of my code:

    SerializableAttribute public class PasswordPopupScreen extends PopupScreen {}
    public PasswordPopupScreen() {}
    Super (new VerticalFieldManager (VERTICAL_SCROLLBAR), DEFAULT_MENU |) DEFAULT_CLOSE);
    HFM HorizontalFieldManager = new HorizontalFieldManager(Manager.VERTICAL_SCROLL |)                                            Manager.NO_HORIZONTAL_SCROLLBAR);

    MyListField myList = new MyListField(0,ListField.FIELD_VCENTER);
    ...

    ...

    HFM. Add (myList);
    Add (HFM);

    }

    ...

    ...
    So do / can a listField even display a vertical scroll bar on a popupscreen? I don't know that I need a manager of vertical and horizontal. All that my screen will have on it is a listField and perhaps a title.

    If anyone can point me in the right direction for what is missing which is originally a vertical scroll bar does not show?

    Thank you.

    Ok. I got it work. My Simulator crashed then I reinstalled it and it worked only. Strange. Well...

    Thank you.

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

    }

  • TouchEvent in Listfield does not work after scrolling in the storm.

    Hello

    My problem is that I have a 250 size listfield, which I add to a verticalfieldmanager1, this verticalfieldmanager1 is added to an another verticalfieldmanager2, then verticalfieldmanager2 is added to horizontalfieldmanager then horizontalfieldmanager is added to the screen.

    By default, I have to display index 220 (to achieve this, I'll focus on the listfield), so when I key to select other items in the list it is not selecting (Touch event does not work). It is to select only the element that has focus.

    I am owner event touch listfield. Could someone please help me in this regard.

    Hello

    I am happy to share that I found a solution for the problem I had.

    Post here as it may help someone. I used the TouchEvent.getX () & TouchEvent.getY)

    directly which solved my problem, previously I was using () TouchEvent.getGlobalX & TouchEvent.getGlobalY ().

    Once again thank you.

  • Move the focus from the listfiled to the particular label (horizontal scrolling problem)

    Hello

    In my application, I have some labels (which are focusable) at the top of the screen that I put in the manager (hfm_lbl) horizontal field with horizontal scrolling.

    After hfm_lbl, I have a listfiled.

    Now when I scroll to the top of the listfiled (i.e.from from bottom to top), the focus moves to top but sets the last menu of the hfm_lbl.

    I want the focus to specify the label of perticular.

    Any help is appreciated...

    Thank you...

    drawFocus won't help with this.

    The problem is only a HFM, when focus activates it by underneath, will automatically set the focus to the last item in the list.  Therefore, substitute this transformation.

    There are actually two options, depending on whether you want to override the onFocus method, or use a FocusChangeListener. I know that some people have had problems with the onFocus() substitution, so recommend the listener. But I never have, so after you will find a sample of the code that I use in this circumstance.

    The thing is that the treatment in the HFM should remember the lastFocusField (one of your labels) when the focus is moved there.  This challenge, I'll leave with you.  Still, he has a variety of options and not better.  So whatever you think probably will work fine.  One option is to set the HFM as a FocusChangeListener for all the domains that are added and then remember the last one, who won the point - then the treatment is autonomous in the HFM.

    The following codes assume that lastFocusField is a field in the HFM, one user had developed on before the ListField moved t.  This method overrides onFocus() in the HFM.

    protected void onFocus (int direction) {}
    super.onFocus (branch);
    If (direction! = 0 & lastFocusField! = null) {}
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
    public void run() {}
    lastFocusField.setFocus ();
    }
    });
    }
    }

    Edit: I think that Simon and I had to answer at the same time.  Just to say, in my experience in this case, you might be able to do it with moveFocus(), or navigationMovement(), but not as easily as onFocus().

Maybe you are looking for