0

您好我想在水平滚动字段管理器上添加多个图像。

水平场管理器的起始点是水平的屏幕中间。

焦点图像的位置(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);
}
4

1 回答 1

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);  
于 2012-04-17T12:43:49.790 回答