Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android NativeScript ListView不是';t更新_Android_Listview_Nativescript_Angular2 Nativescript - Fatal编程技术网

Android NativeScript ListView不是';t更新

Android NativeScript ListView不是';t更新,android,listview,nativescript,angular2-nativescript,Android,Listview,Nativescript,Angular2 Nativescript,所以我有一个这样的列表视图 <ListView height="150" [items]="countries"> <ng-template let-country="item"> <Image src={{country.imgSrc}}></Image> <Label text={{country.name}}></Label&g

所以我有一个这样的列表视图

     <ListView height="150" [items]="countries">
            <ng-template let-country="item">
                <Image src={{country.imgSrc}}></Image>
                <Label text={{country.name}}></Label>
            </ng-template>
     </ListView>
当国家/地区更新时。ListView不会使用新的ListItem更新屏幕。如果我用一个值初始化国家,它会显示ListItem。我在屏幕上放置了一个带有点击侦听器的按钮,即console.log(this.countries)。点击后,新的ListItem最终出现。国家对ListView的绑定不应该自动更新吗

NativeScript 6.0
Android 10通常在这种情况下需要调用refresh()。我不使用angular,在javascript中,这类似于

page.getViewById("listview").refresh();
并具有id=listview,例如

<ListView id-"listview" height="150" [items]="countries">


看起来您正在使用RxObservable订阅来填充您的项目。这意味着您需要使用。例如,异步管道在这里用于列表的属性,以及如何在代码中填充订阅中的项(和)。

我向构造函数添加了private zone
NgZone
,然后像这样包装订阅响应:

this.zone.run(()=>{
   me.countries= countries;
});

来源:

如果它在点击时工作,那么我猜更改检测在之前的时间点没有正常工作。你能分享一个最小的游乐场样本,在那里可以重现这个问题吗。
this.zone.run(()=>{
   me.countries= countries;
});