显示图像

发布于 2024-10-04 20:40:57 字数 136 浏览 0 评论 0原文

您好,我正在开发一个应用程序,我需要在某些条件下显示大量图像。单击下一个按钮时,图像应在屏幕上一张一张地显示。这里所有图像的大小为 360x480。显示图像时,所有其他字段(如下一个和上一个按钮)应添加到屏幕上。如何绘制这些字段任何人都可以在这方面帮助我吗?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乙白 2024-10-11 20:40:57

您可以使用 位图字段。使用 setBitmap() 方法更改图像。

编辑:好的,所以您想做这样的事情,将所有位图的名称放入一个数组中,让按钮的侦听器递增或递减数组索引并显示该位图。因此,您的下一个按钮可能如下所示:

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);
    }

});

这假设您的图像已随您的应用程序预加载并存储在“res”目录中,如果您从在线下载它们,或者它们以加载应用程序的方式存储在文件系统上位图会有些不同。我还没有编译这段代码,所以它可能有一些错误,但这大致就是你想要做的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文