开发者

Displaying images

Hi I am developing a application where I need to display number of images with some conditions. The images should display one by one on the screen when next button is clicked.Here the size of all images is 360x480.When the image is display then all other开发者_开发知识库 fields like next and previous buttons should be added to the screen.How to paint those images.Can anybody please help me in this regard.


You can display images with the BitmapField. Use the setBitmap() method to change the image.

Edit: Ok, so you would want to do something like this, put the names of all your bitmaps in an array, have the button's listeners increment or decrement the array index and display that bitmap. So your next button might look like this:

ButtonField nextButton = new ButtonField("Next");
nextButton.setChangeListener(new FieldChangeListener(){
    public void fieldChanged(Field field, int context)
    {
        if(arrayIndex + 1 >= bitmapArray.length)
        {
            return;
        }
        arrayIndex++;
        Bitmap image = Bitmap.getBitmapResource(bitmapArray[arrayIndex])
        myBitmapField.setBitmap(image);
    }

});

This assumes that your images are preloaded with your app and are stored in the 'res' directory, if you're downloading them from online or they're stored on the filesystem the way you load the bitmap will be somewhat different. I haven't compiled this code so it may have some bugs but this is roughly what you want to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜