大家好,我尝试添加一个图像到viewflipper页面时,有一些麻烦,我从db4o数据库中拉出位图(不确定它是否是编码或者它使用的东西是在搞乱我向上)。ViewFlipper不加载位图图像
private void setImageView() {
page = (ViewFlipper) findViewById(R.id.viewFlipper1);
int temp = DigPlayDB.getInstance(getBaseContext()).getPlaysDBSize();
for(int j = 0; j < temp; ++j){
test.add(DigPlayDB.getInstance(getBaseContext()).getPlayByInt(j).getImage());
test1.add(DigPlayDB.getInstance(getBaseContext()).getPlayByInt(j).getPlayName());
}
for(int i=0;i<temp; i++)
{
// This will create dynamic image view and add them to ViewFlipper
setFlipperImage(test.get(i));
}
然后对图像的设置并添加视图页面
private void setFlipperImage(Bitmap image){
ImageView _image = new ImageView(getApplicationContext());
//_image.setBackgroundDrawable(new BitmapDrawable(getResources(), image));
_image.setImageBitmap(image);
page.addView(_image);
Log.d("db", "" + image);
}
它的工作原理后立即将图片添加到数据库中,但只是图像,旧的图像,以及当我重新启动应用程序时,即使它说它是从我设置的调试日志中执行的,也不会加载。我想最后一个显示出来,因为它仍然可能在某处的缓存中,但存储在数据库中而不是在缓存中的较旧的不是正确编码或某种东西。任何帮助都是极好的。谢谢!
编辑:我应该提到“测试”是Bitmaps的数组列表。
如何将图像存储在db4o中?作为字节数组?或者你尝试存储一个android类实例的对象。 – Gamlor
我将图像作为位图对象存储在我在应用程序中使用的类结构之一中。 – user1799107