【问题标题】:Appcelerator : animate the backgroundColor of a listview itemAppcelerator : 为列表视图项的背景颜色设置动画
【发布时间】:2016-03-07 13:56:59
【问题描述】:

我正在尝试为 listview item 子项的 backgroundColor 属性设置动画。

这是代码

var itemToUpdate = myListView.getSections();
itemToUpdate = itemToUpdate[0].getItemAt(myPos);
//itemToUpdate.child_to_update.backgroundColor = myColor; //this works , but without animation
itemToUpdate.child_to_update.animate({
    backgroundColor : myColor,
    duration : 450
});
myListView.sections[0].updateItemAt(myPos , itemToUpdate);

【问题讨论】:

  • 请尝试将您的问题表述为一个问题,并确保您的代码是完整的。 catToUpdate 未定义,例如
  • 对不起,catToUpdate -> itemToUpdate

标签: ios listview appcelerator listviewitem appcelerator-titanium


【解决方案1】:

Ti.UI.ListSection.getItemAt() 方法为您提供ListDataItem。此对象不包含对实际视图的引用,而是包含用于使用您定义的 ListView ItemTemplates 生成视图的数据。这对性能很有好处,但这意味着您不能直接操作视图并使用像animate() 这样的方法。

TL;DR 使用 ListView 无法实现您想要的。考虑改用 TableView。

【讨论】:

  • 我想是因为这个。我更喜欢表演,所以暂时没有动画。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-18
  • 1970-01-01
  • 1970-01-01
  • 2019-05-29
  • 1970-01-01
  • 2014-05-14
  • 2016-01-02
相关资源
最近更新 更多