我想制作这种类型的自定义列表。我如何在黑莓中制作这种类型的列表?
我有一个红色的彩色图像&我必须适应未来未来5日n个电流月红图像&近到我要添加四个文本。我有那张白色的背景图片。 如何在黑莓中做到这一点。请帮助我...
我想制作这种类型的自定义列表。我如何在黑莓中制作这种类型的列表?
我有一个红色的彩色图像&我必须适应未来未来5日n个电流月红图像&近到我要添加四个文本。我有那张白色的背景图片。 如何在黑莓中做到这一点。请帮助我...
您可以使用berrytutorials博客中的“Create a Custom Listfield - Change Highlight Color when Scrolling”来了解如何创建listField
。在drawListRow
方法中,您可以获取图形对象并根据需要绘制列表行。
使用graphics.drawText()
绘制文本,graphics.drawBitmap()
绘制图片等
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++;
}
这不是几个原因一个好的解决方案。说如果我有一百行,它会创建几百个领域和经理,这将影响应用程序的性能。此外,如果用于像珍珠等小屏幕的设备,这将失败惨败。 – user1121332 2012-02-16 10:46:35
@ user1121332:是的,我肯定同意..但对我来说,要求不是100条记录......并且在使用ListField时遇到了一些问题。因此,去了这个方法。 – 2012-02-16 11:40:15