我将如何在黑莓中制作这种类型的列表?

时间:2012-02-16 09:27:15

标签: blackberry

我想制作这种类型的自定义列表。

enter image description here

我有那个红色的图像&我必须适应即将到来的5个日期n当月的红色图像&接近我要添加四个文本。我有那个列表的白色背景图片。 如何在黑莓手机上做。请帮帮我...

2 个答案:

答案 0 :(得分:1)

您可以使用berrytutorials博客中的“Create a Custom Listfield - Change Highlight Color when Scrolling”来了解如何创建listField。在drawListRow方法中,您可以获取图形对象并根据需要绘制列表行。

使用graphics.drawText()绘制文字,graphics.drawBitmap()绘制图片等。

答案 1 :(得分:0)

This was my requirement Hence I did not go for the listField option...
Try it may be helpful..

listVFM = new VerticalFieldManager();

rowHFM = new HorizontalFieldManager[10];

imageBitmapField = new BitmapField[10];

img_bitmap = Bitmap.getBitmapResource("image.png");

descriptionLabel = new LabelField[10];

discountLabel = new LabelField[10];

goButton = new RoundedCustomButtonField[10];

goSelectBitmap = Bitmap.getBitmapResource("btnSelectGo.png");

goUnselectBitmap = Bitmap.getBitmapResource("btnUnselectGo.png");


row_height = 90;

int j=0;

int row_count = 0;

for(int i=0; i<10; i++) {

    rowHFM[row_count] = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_HEIGHT) {

        protected void sublayout(int maxWidth, int maxHeight) {

            int displayWidth = Display.getWidth();
            int displayHeight = 80;

            super.sublayout( displayWidth, displayHeight);
            setExtent( displayWidth, displayHeight);
        }

    };


    rowHFM[row_count].setPadding(2, 2, 2, 2);

    imageBitmapField[row_count] = new BitmapField(img_bitmap, BitmapField.FIELD_VCENTER | BitmapField.VCENTER |                     BitmapField.USE_ALL_HEIGHT) {

        protected void layout(int maxWidth, int maxHeight)
        {
            int displayWidth = 85;
            int displayHeight = 70;

            super.layout( displayWidth, displayHeight);
            setExtent( displayWidth, displayHeight);
        }   
    };

    imageBitmapField[row_count].setPadding(0,0,0,4);


    descriptionLabel[row_count] = new LabelField("Description.....") {

        protected void layout(int maxWidth, int maxHeight) {

            int displayWidth = (int)(Display.getWidth()/2.6);
            int displayHeight = maxHeight;

            super.layout( displayWidth, displayHeight);
            setExtent( displayWidth, displayHeight);
        }   

    };


    descriptionLabel[row_count].setPadding(5,0,0,2);

    discountLabel[row_count] = new LabelField(discountRate + "%") {

        protected void layout(int maxWidth, int maxHeight) {

            int displayWidth = (int)(Display.getWidth()/4.8);
            int displayHeight = maxHeight;

            super.layout( displayWidth, displayHeight);
            setExtent( displayWidth, displayHeight);
        }   

    };


    discountLabel[row_count].setPadding(5,0,0,2);

    goButton[row_count] = new CustomButtonField("go",goSelectBitmap ,goUnselectBitmap, Field.FIELD_VCENTER              |Field.USE_ALL_HEIGHT);



    goButton[row_count].setPadding(0,0,0,2);

    goButton[row_count].setChangeListener(new FieldChangeListener() {

        public void fieldChanged(Field field, int context) {

            //code....
        }

    });

    rowHFM[row_count].add(imageBitmapField[row_count]);

    rowHFM[row_count].add(descriptionLabel[row_count]);

    rowHFM[row_count].add(discountLabel[row_count]);

    rowHFM[row_count].add(goButton[row_count]);

    listVFM.add(rowHFM[row_count]);

    row_count++;

}