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

Tags: BlackBerry Developers

Similar Questions

  • 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

  • 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()));
    }
    
  • vertical scroll Limit in pane

    Hello

    I use a panemanager to display a list of uneven objects in 7 parts. When I scroll down, some of the components have a blank white background. This is because the components need to have an equal amount of objects is not for that.

    My question is how to limit scrolling to each pane did not go beyond the last object.

    Another question is, how do I set the HorizontalScrollableTitleView to be in a fixed position, so it doesn't scroll on the screen (such as the title bar)

    Thanks in advance!

    Follow these steps

    Manager is not any scrolling

    Manager B has vertical scrolling

    Add B has (as A.add (B))

    Add an inScreen linke (add (a))

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

  • Horizontal scrolling text change number field on the 6.0 devices

    Greetings,

    I'm trying to create a horizontal scrolling editable text field.  The general approach is to add an EditField to a HorizontalFieldManager who has the style bit HORIZONTAL_SCROLL.  It works very well on all devices up to 5.0.  However, I'm a problem on 6.0 devices.

    When the user tries to scroll right well that focused on this field, the text moves to the left and turns off visible region of the horizontal field manager.  This can also be reproduced when you tap the (torch device) and continue dragging to the left until it will disappear from the screen.

    Now, I understand that this happens because the edit field itself has a width of ~ infinite because its container Manager has scrolling enabled, but is not an acceptable user experience.

    I tried to limit the width for the edit field to the width of the text, but which caused exception argument not in conformity.  I tried a RichTextField with style hack USE_TEXT_WIDTH bit by directing the keyDown to setText field entries but have other problems.

    My remaining solution is to restrict the limit of characters for the width of the Manager, the text on the new line that I saw almost all others apply or write my own implementation of scroll.  The only exception is the address bar of the BlackBerry native browser application that seems to be a custom implementation.

    Reference:

    http://supportforums.BlackBerry.com/T5/Java-development/sample-code-scrollable-one-line-text-input-f...

    Any thoughts would be appreciated,

    Thank you.

    Thank you, setScrollingInertial (false) was actually what I was looking for.

    I was not able to implement your approach correctly but I was able to complete another work autour, I had before with the help of setScrollingInertial (false).

    Instead, I used a scrolling listener to limit scrolling based on the length of the text (new scrolling when limits are reached).  Without setScrollingInertial (false), the scrollChanged reminder would have been called multiple times all by animating the inertia.

    Unfortunately, I won't be able to apply this hotfix, because my generation must take over the 4.7 and setScrollingInertial is 5.0 + (customer doesn't want additional constructions).  However, this will be useful for future projects.

  • 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

    {

    {);

  • Film scrolling problem

    Once more, I want to thank SwapnilVJ for help in my previous post.

    I now have my film scrolling without errors.

    I just want to scroll so far. I put limits and it stops exactly where I want it. -No problem.

    Problem is: if I don't get up to the upper and lower scroll limit, it works as it should - both scrolling up and down. Once happens to limit scrolling, it stops as it is supposed to, but it does not start to high do scroll in the opposite direction.

    I realize that I set the speed = speed at the speed * 0 (to stop), but I don't know what to wear so he can start the scroll in the opposite direction, once a button is pressed again.

    My code is:

    scroll buttons

    Up button

    upArrow.addEventListener (MouseEvent.MOUSE_DOWN, scrollDownPress);

    function scrollDownPress(event:MouseEvent):void
    {
    btn_movie.addEventListener (Event.ENTER_FRAME, btn_movieScrollDown);

    }

    upArrow.addEventListener (MouseEvent.MOUSE_UP, scrollDownRelease);

    function scrollDownRelease(event:MouseEvent):void
    {
    btn_movie. RemoveEventListener (Event.ENTER_FRAME, btn_movieScrollDown);

    }

    upArrow.addEventListener (MouseEvent.ROLL_OVER, scrollDownRollOver);

    function scrollDownRollOver(event:MouseEvent):void
    {
    upArrow.gotoAndStop (2);

    }

    upArrow.addEventListener (MouseEvent.ROLL_OUT, scrollDownRollOut);

    function scrollDownRollOut(event:MouseEvent):void
    {
    upArrow.gotoAndStop (1);

    }

    the button

    downArrow.addEventListener (MouseEvent.MOUSE_DOWN, scrollUpPress);

    function scrollUpPress(event:MouseEvent):void
    {
    btn_movie.addEventListener (Event.ENTER_FRAME, btn_movieScrollUp);

    }

    downArrow.addEventListener (MouseEvent.MOUSE_UP, scrollUpRelease);

    function scrollUpRelease(event:MouseEvent):void
    {
    btn_movie. RemoveEventListener (Event.ENTER_FRAME, btn_movieScrollUp);

    }

    downArrow.addEventListener (MouseEvent.ROLL_OVER, scrollUpRollOver);

    function scrollUpRollOver(event:MouseEvent):void
    {
    downArrow.gotoAndStop (2);

    }

    downArrow.addEventListener (MouseEvent.ROLL_OUT, scrollUpRollOut);

    function scrollUpRollOut(event:MouseEvent):void
    {
    downArrow.gotoAndStop (1);

    }



    Scroll buttons

    var speed: number = 3;

    Scroll to the top

    btn_movie.addEventListener (Event.ENTER_FRAME, btn_movieScrollUp);
    function btn_movieScrollUp(event:Event):void
    {
    btn_movie.y = btn_movie.y - speed;

    If (btn_movie.y <-142) {}
    Speed = speed * 0;
    }
    }

    Scroll down

    btn_movie.addEventListener (Event.ENTER_FRAME, btn_movieScrollDown);
    function btn_movieScrollDown(event:Event):void
    {
    btn_movie.y = btn_movie.y + speed;

    If (btn_movie.y > 0) {}
    Speed = speed * 0;
    }
    }

    Thanks in advance for any help

    I thought about it.

    New code below:

    Scroll buttons

    var speed: number = 3;

    Scroll to the top

    function btn_movieScrollUp(event:Event):void
    {
    btn_movie.y = btn_movie.y - speed;

    If (btn_movie.y<>
    Speed = 0;
    }
    If (btn_movie.y >-142) {}
    Speed = 3;
    }

    }

    Scroll down

    function btn_movieScrollDown(event:Event):void
    {
    btn_movie.y = btn_movie.y + speed;

    If (btn_movie.y > 0) {}
    Speed = 0;
    }
    If (btn_movie.y<>
    Speed = 3;
    }

    }

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

Maybe you are looking for

  • I want to spend some of my emails from the IMAP server and save them on my hard drive

    I'm an iMac user who just flipped to Thunderbird. I can not all topics that deal with this issue. I see the 'local folders' at the bottom of my email accounts. This is where I can implement the records to move email messages on my hard drive. I have

  • Download safari again?

    I have a problem with the virus and I have read that I need to delete safari, because I can download it again after. But I can't find anywhere Heeeeelp

  • New Deskjet F4185 All in One or any other printer Deskjet F4185 software needed, Pls!

    Hello world Can someone help me get a new Deskjet F4185 or any other printer Deskjet F4185 software. Your recommendation is much appreciated. Thank you.

  • HBO Go on the dashboard

    Any chance to add HBO Go for the video channels available on the dashboard? I know it's a channel that not everyone can use, you need an eligible account of HBO, but, IMO, is no different from Amazon on demand where you need to pay individual content

  • W520 - second RAM does not not - 1-3-3-1 beep

    Hello I am trying to upgarde my Ram W520. I have 2 slots, one is filled with the samsung 1333 mhz DDR3 4 GB 10600 supplied with the computer. I bought a new Ram of 4 GB 1333 mhz DDR3 CAS9 10660 mediamarkt When I plug in I have a black screen with 1-3