大家好,当我尝试将图像添加到 viewflipper 页面时遇到了一些麻烦,我正在从 db4o 数据库中提取位图(不确定是编码还是它使用的东西让我感到困惑)。
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);
}
它在我将图像添加到数据库后立即工作,但只是该图像,旧图像以及当我重新启动应用程序时不会加载,即使它说它们是从我设置的调试日志中加载的。我认为最后一个出现了,因为它仍然可能在某个地方的缓存中,但是存储在数据库中而不是缓存中的旧的没有正确编码或其他东西。任何帮助都是极好的。谢谢!
编辑:我应该提到“测试”是位图的数组列表。