views:

194

answers:

1
searchlist = new FileList(list_vector,ind,j);//a custom list field
searchlist.setRowHeight(40);
searchListManager = new VerticalFieldManager(
    Manager.VERTICAL_SCROLL |Manager.VERTICAL_SCROLLBAR)

searchListManager.add(searchlist);  
objManager.add(searchListManager);
HomeScreen1.this.add(header_manager);
HomeScreen1.this.add(objManager);   

//after few lines of code
 button_manager.add(Previous);
 button_manager.add(Next);
 objManager.add(button_manager); 

now my problem is when i scroll over the list field then next n previous are not visible but when i press key up n down then they get only visible

what to do???????????

+1  A: 

Try to implement searchListManager as a scrollable VerticalManager with fixed size (Display height - header manager height - button manager height)

UPDATE Code to try:

class Scr extends MainScreen implements ListFieldCallback {
    int DISPLAY_WIDTH = Display.getWidth();
    int DISPLAY_HEIGHT = Display.getHeight();
    Vector mItems = new Vector();
    ListField mListField = new ListField();
    SizedVFM mListManager = new SizedVFM(DISPLAY_WIDTH, DISPLAY_HEIGHT - 50);

    ButtonField mPrevButtonField = new ButtonField("Previous",
            ButtonField.CONSUME_CLICK);
    ButtonField mNextButtonField = new ButtonField("Next",
            ButtonField.CONSUME_CLICK);

    HorizontalFieldManager mButtonsManager = new HorizontalFieldManager(
            FIELD_HCENTER);

    public Scr() {
        for (int i = 1; i < 31; i++) {
            mItems.addElement("item " + String.valueOf(i));
        }

        mListField.setCallback(this);
        mListField.setSize(30);
        add(mListManager);
        mListManager.add(mListField);

        mPrevButtonField.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.inform("Previouse pressed");
            }
        });

        mNextButtonField.setChangeListener(new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                Dialog.inform("Next pressed");
            }
        });

        mButtonsManager.add(mPrevButtonField);
        mButtonsManager.add(mNextButtonField);
        add(mButtonsManager);
    }

    public void drawListRow(ListField field, Graphics g, int i, int y, int w) {
        // Draw the text.
        String text = (String) get(field, i);
        g.drawText(text, 0, y, 0, w);
    }

    public Object get(ListField listField, int index) {
        return mItems.elementAt(index);
    }

    public int getPreferredWidth(ListField listField) {
        return DISPLAY_WIDTH;
    }

    public int indexOfList(ListField listField, String prefix, int start) {
        return 0;
    }
}

class SizedVFM extends VerticalFieldManager {
    int mWidth;
    int mHeight;

    public SizedVFM(int width, int height) {
        super(VERTICAL_SCROLL | VERTICAL_SCROLLBAR);
        mWidth = width;
        mHeight = height;
    }

    public int getPreferredHeight() {
        return mHeight;
    }

    public int getPreferredWidth() {
        return mWidth;
    }

    public void setHeight(int height) {
        mHeight = height;
    }

    protected void sublayout(int maxWidth, int maxHeight) {
        super.sublayout(maxWidth, maxHeight);
        setExtent(getPreferredWidth(), getPreferredHeight());
    }
}

And the result should be like that:
alt text

Max Gontar
its not working!!!!!!!!!
SWATI
should work now ;)
Max Gontar
thanks it workrd on device but not on simulator
SWATI
you're welcome!
Max Gontar