Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12588] Android: Change image property of imageView doesn't work in tableviewRow

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-03-13T12:43:33.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.0.2
ComponentsAndroid
LabelsCommunity
ReporterJong Eun Lee
Assigneejithinpv
Created2013-01-22T02:55:34.000+0000
Updated2017-03-21T21:31:57.000+0000

Description

Problem

When imageView in TableViewRow and Android, setImage doesn't work (just work 1st time).

Tested on

iOS 6 simulator Razr Droid OS 2.3.5

To reproduce

run below example, click row multiple times.

Snippet code

 
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});

var table = Ti.UI.createTableView();
var row = Ti.UI.createTableViewRow({
    height : 100
});
var img = Ti.UI.createImageView({
    width : 100,
    height : 100
});

row.add(img);
table.data = [row];
win.add(table);
win.open();

var srcs = [
    "http://t3.gstatic.com/images?q=tbn:ANd9GcQUkHHr21JB_gUXFHFVe-uXFEG2M3D25Vy6DWaifLf_1pZkwwfGkg",
    "http://t0.gstatic.com/images?q=tbn:ANd9GcQ2hy-N72tStiinhPW1qUPT3kduibk-e5ufAeZtq3NI9GPRsLCl",
    "http://t2.gstatic.com/images?q=tbn:ANd9GcSZLz8YqLQYatlgtRIR8qQ0Dl6tD1AoR1NYby8zJbBln1oX55UE",
    "http://t3.gstatic.com/images?q=tbn:ANd9GcTSZ7Rg1kzKjqtvf06-aDgQHCvE7SKB6uh_JIdfy_e4Jj-cPuiy"
];

var index=0;
table.addEventListener('click',function(e){ 
    var src = srcs[(index++)%4];
    Ti.API.info(src);
    img.setImage(src); //doesn't work! (just work 1st setImage)
    //img.setBackgroundImage(src); //work!
});

Additional info

- When imageView in window, setImage work every time.
 
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});

var img = Ti.UI.createImageView({
    width : 100,
    height : 100
});
win.add(img);
win.open();

var srcs = [
    "http://t3.gstatic.com/images?q=tbn:ANd9GcQUkHHr21JB_gUXFHFVe-uXFEG2M3D25Vy6DWaifLf_1pZkwwfGkg",
    "http://t0.gstatic.com/images?q=tbn:ANd9GcQ2hy-N72tStiinhPW1qUPT3kduibk-e5ufAeZtq3NI9GPRsLCl",
    "http://t2.gstatic.com/images?q=tbn:ANd9GcSZLz8YqLQYatlgtRIR8qQ0Dl6tD1AoR1NYby8zJbBln1oX55UE",
    "http://t3.gstatic.com/images?q=tbn:ANd9GcTSZ7Rg1kzKjqtvf06-aDgQHCvE7SKB6uh_JIdfy_e4Jj-cPuiy"
];

var index=0;
win.addEventListener('click',function(e){ 
    var src = srcs[(index++)%4];
    Ti.API.info(src);
   img.setImage(src);
});

Comments

  1. Eduardo Gomez 2013-02-02

    Hello JongEun, I did test _setImage_ worked just once. Tested _setBackgroundImage_ method which achieves the same result but multiple times. What would be the need to use setImage then?
  2. Jong Eun Lee 2013-02-05

    When you use setBackgroundImage instead of setImage in TableView, Tableview have a scroll performance problem. 'setBackgroundImage' is too slower then 'setImage'.
  3. jithinpv 2013-03-13

    Issue does not reproduces with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4
  4. Lee Morris 2017-03-21

    Closing ticket as the issue cannot be reproduced.

JSON Source