无法更改列表视图中所选项目的背景颜色。
我试图理解这一点。但是解决方案是有角度的,我不知道如何在 javascript 中使用它。
更改 ListView 中当前所选项目的背景颜色的问题 - Nativescript/Angular2
onItemTap: function (args) {
console.log('Item with index: ' + args.index + ' tapped');
args.object.backgroundColor = "#3489db";
},
在这里我可以更改完整列表视图的背景。
操场样本。https://play.nativescript.org/?template=play-js&id=KZeq3j
我只希望所选项目的背景发生变化。
我在这里为你更新了游乐场。args.object 为您提供列表视图本身。
onItemTap: function (args) {
for (var i = 0; i < this.countries.length; i++) {
this.countries[i].bgColor = "#FFFFFF";
}
console.log(this.countries[args.index])
this.countries[args.index].bgColor = "#3489db";
args.object.refresh();
},
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句