문제

BlackBerry Development.my 응용 프로그램에는 각 항목 문자열이있는 5 개의 목록 항목이 포함되어 있습니다. 내 요구 사항은 하나의 셀을 선택한 경우 확대해야하며 다른 항목은 자동으로 공간을 자동으로 조정해야합니다. 일반보기에 대한 목록 항목 하나 및 사용자가 이전보다 높이가 더 높을 때 선택한 항목을 표시하는 데 하나의 이미지의 두 가지 유형의 이미지를 촬영했습니다.

그러나 문제는 다음 항목에 확대되고 겹치는 한 항목을 선택하고 전체 항목을 표시하지 않고 공백을 조정하지 않는 것입니다. 누구 든지이 해결책을 줄 수 있습니까?다음 코드 스 니펫을 사용하고 있습니다 ....

_listField.setCallback(this);
    _listField.setRowHeight(45);
    _listField.setChangeListener(this);
.

공용 void drawListrow (listfield arg0, 그래픽 그래픽, int 색인, int y, int width) {

    if (listFieldIndex != index) {

        graphics.drawBitmap(0, y, listBkgrnd.getWidth(), listBkgrnd
                .getHeight(), listBkgrnd, 0, 0);

        graphics.setColor(0xAA0000);
        graphics.setFont(this.getFont().derive(Font.BOLD, 17));
        graphics.drawText(((Station) _stationList.elementAt(index))
                .getStationName(), 15, y + 15, 0,
                (listBkgrnd.getWidth() - 70));

        graphics.setColor(0x770000);
        graphics.setFont(this.getFont().derive(Font.PLAIN, 13));

        // graphics.drawText(
        // ((Station) _stationList.elementAt(index)).getCT(), 15,
        // y + 40, 0, (listBkgrnd.getWidth() - 65));

    } else {

        graphics.drawBitmap(0, y, playBkgrnd.getWidth(), playBkgrnd
                .getHeight(), playBkgrnd, 0, 0);

        graphics.setColor(0xAA0000);
        graphics.setFont(this.getFont().derive(Font.BOLD, 17));
        graphics.drawText(((Station) _stationList.elementAt(index))
                .getStationName(), 15, y + 15, 0,
                (playBkgrnd.getWidth() - 70));

        graphics.setColor(0x770000);
        graphics.setFont(this.getFont().derive(Font.PLAIN, 13));

        graphics.drawText(
                    s.getCT(), 15,
                    y + 40, 0, (playBkgrnd.getWidth() - 65));
    }
}
.

도움이 되었습니까?

해결책

목록 BlackBerry의 필드는 모든 행이 동일한 높이라고 가정합니다.

원하는 효과를 얻으려면 VerticalFieldManager에서 선택 가능한 필드를 무리를 사용하면 ListField와 비슷한 효과를 얻을 수 있습니다.항목을 집중할 수있게하고 초점을 잃거나 손실 될 때마다 updateLayout를 호출 한 다음 layout 메소드에서 초점을 맞추거나 아닌지에 따라 필드의 높이를 설정하십시오.다음 개요와 같은 것 :

public class CustomListFieldItem extends Field {

    public boolean isFocusable() {
        return true;
    }

    protected void onFocus(int direction) {
        super.onFocus(direction);
        updateLayout();
    }

    protected void onUnfocus() {
        super.onUnfocus();
        updateLayout();
    }

    protected void layout(int width, int height) {
        if (isFocus()) {
            setExtent(width, playBkgrnd.getHeight());
        }
        else {
            setExtent(width, listBkgrnd.getHeight());
        }

    }

    protected void paint(Graphics graphics) {
        if (isFocus()) {
            // draw selected item
        }
        else {
            // draw unselected item
        }
    }

}
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top