为什么Android中的图像不显示在TableView上?

为什么Android中的图像不显示在TableView上?,android,titanium,android-imageview,titanium-mobile,appcelerator-mobile,Android,Titanium,Android Imageview,Titanium Mobile,Appcelerator Mobile,我正在开发Tianium 2.1.3,并在iOS和Android上进行部署。 我在Android上的ImageView的TableView中显示图像时遇到问题,如果我点击搜索栏并显示键盘,图像就会显示出来,或者如果我滚动TableView,图像就会无缘无故地出现和消失。似乎除非我在TableView上强制进行布局刷新,否则图像不会被渲染。 图像在Android和iOS中的加载方式相同,如下所示: var itemIconHolder = Titanium.UI.createView({

我正在开发Tianium 2.1.3,并在iOS和Android上进行部署。 我在Android上的ImageView的TableView中显示图像时遇到问题,如果我点击搜索栏并显示键盘,图像就会显示出来,或者如果我滚动TableView,图像就会无缘无故地出现和消失。似乎除非我在TableView上强制进行布局刷新,否则图像不会被渲染。 图像在Android和iOS中的加载方式相同,如下所示:

var itemIconHolder = Titanium.UI.createView({
    width : '100dp',
    left : '55dp',
    height : "100%"
});

var itemIcon = Titanium.UI.createImageView({
    left : '0dp',
    height : '100%',
});

var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, "thumb-" + filename);
itemIcon.image = f;

itemIconHolder.add(itemIcon);
这个问题不会发生在iOS中,在iOS设备/模拟器上,这种行为是正常且完美的,但在Android设备/模拟器上会发生。 我必须在Android中以不同的方式加载图像吗?我错过什么了吗?我希望有人能在这方面帮助我。 提前谢谢

编辑

我尝试了以下方法:

itemIcon.image = f.read();


但是,直到我制作了某种东西,使TableView以某种方式刷新,图像才被渲染。

我在Android上找到了解决这个问题的方法。 由于需要对图像进行布局刷新才能正确渲染,因此我所做的是对表格进行动画制作,在一个方向上移动它1dp,在完成所述动画时,我再次对其进行动画制作,以将其恢复到原始位置。这是我使用的代码:

var table_bottom = '-1dp'

var tableAnimation = Ti.UI.createAnimation({
    bottom : table_bottom,
    duration : 100
});
tableAnimation.addEventListener('complete', function(e){
    var table_bottom = '50dp';
    if (osname === 'android') 
    {
        table_bottom = '0dp'
    }
    table.animate({
        bottom : table_bottom,
        duration : 100
    });
});

我在Tianium SDK 2.1.3和Tianium 3.0中都遇到过这种问题。

您尝试过itemIcon.image=f.read;?是的,我也试过了,但是没有任何改变。你为什么要用2.1.3?它非常古老,自那时以来,已经修复了许多与TableView相关的bug。我建议你看看appcelerator JIRA。另一方面,您能否在tableView代码中提供具体信息,因为3.1将使我们失去对Android 2.2及以下版本的支持,目前我们也希望为这些用户提供支持。
var table_bottom = '-1dp'

var tableAnimation = Ti.UI.createAnimation({
    bottom : table_bottom,
    duration : 100
});
tableAnimation.addEventListener('complete', function(e){
    var table_bottom = '50dp';
    if (osname === 'android') 
    {
        table_bottom = '0dp'
    }
    table.animate({
        bottom : table_bottom,
        duration : 100
    });
});