您好我想在水平滚动字段管理器上添加多个图像。
水平字段管理器的起始点水平位于屏幕的中间。
焦点图像(y坐标)的位置形成另一个图像。
当焦点从图像更改为右侧而不是滚动图像右侧时。
如果焦点从图像更改为左侧而不是向左滚动图像到屏幕左侧的完整宽度。
但水平屏幕中间的图像起点。
这是我的代码
public class MainClass extends MainScreen{
private HorizontalFieldManager hManager;
private HorizontalFieldManager[] hBitmap;
int Height = Display.getHeight();
int Width = Display.getWidth();
private PictureScrollField pictureScrollField;
private String footer_images[] = new String[]
{"ajtak.jpg","assiant.jpg","astha.jpg","fox_news.jpg",
"cnbc.jpg","india_news.jpg","zee.jpg"};
private Bitmap [] bitmaps;
private ScrollEntry[] entries;
public MainClass()
{
hManager = new HorizontalFieldManager()
{
protected void sublayout(int maxWidth,int maxHeight)
{
super.sublayout(maxWidth, maxHeight);
setExtent(Width, 60);
}
};
bitmaps = new Bitmap[footer_images.length];
entries = new ScrollEntry[footer_images.length];
for(int i =0; i < footer_images.length;i++)
{
bitmaps[i] = Bitmap.getBitmapResource(footer_images[i]);
entries[i] = new ScrollEntry(bitmaps[i], "", "");
}
pictureScrollField = new PictureScrollField(36, 36);
pictureScrollField.setData(entries, 0);
pictureScrollField.setImageDistance(38);
pictureScrollField
.setHighlightStyle(HighlightStyle.ILLUMINATE);
pictureScrollField.setHighlightBorderColor(Color.GREEN);
pictureScrollField.setBackground(BackgroundFactory
.createSolidTransparentBackground(0x212424, 150));
pictureScrollField.setLabelsVisible(false);
pictureScrollField.setFocusListener(new FocusChangeListener() {
public void focusChanged(Field field, int eventType) {
if (pictureScrollField.isFocus()) {
switch (pictureScrollField.getCurrentImageIndex()) {
case 0:
setMargin(0, 0, 20, 0);
break;
case 1:
setMargin(0, 0, 20, 0);
break;
case 2:
setMargin(0, 0, 20, 0);
break;
case 3:
setMargin(0, 0, 20, 0);
break;
case 4:
setMargin(0, 0, 20, 0);
break;
case 5:
setMargin(0, 0, 20, 0);
break;
default:
break;
}
}
}
});
hManager.add(pictureScrollField);
add(hManager);
}
答案 0 :(得分:0)
试试这个
private PictureScrollField _pictureScrollField;
ScrollEntry[] entries = new ScrollEntry[ 4 ];
entries[0] = new ScrollEntry(Bitmap.getBitmapResource("image1.jpg"), "BlackBerry", "image 1");
entries[1] = new ScrollEntry(Bitmap.getBitmapResource("image2.jpg"), "Blue logo", "image 2");
entries[2] = new ScrollEntry(Bitmap.getBitmapResource("image3.jpg"), "Black logo", "image 3");
entries[3] = new ScrollEntry(Bitmap.getBitmapResource("image3.jpg"), "Building", "image 4");
_pictureScrollField = new PictureScrollField(150, 100);
_pictureScrollField.setData(entries, 0);
add(_pictureScrollField);