RadListView.scrollToIndex()似乎总是在当前窗口的底部显示所选项目 - 无论该项目是否已经可见。
是否有类似RadListView.isVisible()的函数?
答案 0 :(得分:0)
我刚用scrollToIndex()
测试了给定方案,但无法重现这种行为。所选行始终显示在屏幕顶部。您可以查看我的示例代码。
主page.xml
<Page loaded="onPageLoaded" xmlns:lv="nativescript-telerik-ui-pro/listview" xmlns="http://www.nativescript.org/tns.xsd">
<lv:RadListView id="rdid" loaded="radlistviewlaoded" items="{{ dataItems }}" >
<lv:RadListView.listViewLayout>
<lv:ListViewLinearLayout scrollDirection="Vertical"/>
</lv:RadListView.listViewLayout>
<lv:RadListView.itemTemplate>
<StackLayout orientation="vertical">
<Label fontSize="20" text="{{ itemName }}"/>
<Label fontSize="14" text="{{ itemDescription }}"/>
</StackLayout>
</lv:RadListView.itemTemplate>
</lv:RadListView>
</Page>
主page.ts
import { EventData } from "data/observable";
import { Page } from "ui/page";
import { HelloWorldModel } from "./main-view-model";
import { ObservableArray } from "data/observable-array";
import { RadListView } from "nativescript-telerik-ui-pro/listview";
import {setTimeout} from "timer"
// Event handler for Page "navigatingTo" event attached in main-page.xml
export function onPageLoaded(args: EventData) {
// Get the event sender
var page = <Page>args.object;
var listview:RadListView = <RadListView> page.getViewById("rdid");
console.log("listview visibility "+listview.visibility);
//listview.scrollToIndex(3);
var array = new ObservableArray();
for(var i=0;i<20;i++){
array.push({itemName:"Name "+i, itemDescription:"desc "+i});
}
setTimeout(function(){
listview.scrollToIndex(3)
}, 2000)
page.bindingContext = {dataItems:array};
}
export function radlistviewlaoded(args:EventData){
console.log("RadListView loaded");
}
关于第二个问题,您可以使用loaded
事件,以防您想知道视频何时加载到屏幕上。如果您想知道RadListview是否可见,您可以使用visibility属性。