ListView | API - NativeScript

Represents a view that shows items in a vertically scrolling list.

Summary

Constructors

constructor

Properties

android

Gets the native [android widget](http://developer.android.com/reference/android/widget/ListView.html) that represents the user interface for this component. Valid only when running on Android OS.

ios

Gets the native [iOS view](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/) that represents the user interface for this component. Valid only when running on iOS.

iosEstimatedRowHeight

Gets or set the estimated height of rows in the ListView. The default value is 44px.

itemIdGenerator

itemIdGenerator: (item: any, index: number, items: any) => number

itemTemplate

Gets or set the item template of the ListView.

itemTemplateSelector

itemTemplateSelector: string | (item: any, index: number, items: any) => string

A function that returns the appropriate ket template based on the data item.

itemTemplates

Gets or set the list of item templates for the item template selector

items

Gets or set the items collection of the ListView. The items property can be set to an array or an object defining length and getItem(index) method.

rowHeight

Gets or set row height of the ListView.

separatorColor

Gets or set the items separator line color of the ListView.

String value used when hooking to itemLoading event.

String value used when hooking to itemTap event.

loadMoreItemsEvent

Static

loadMoreItemsEvent: string

String value used when hooking to loadMoreItems event.

Methods

isItemAtIndexVisible

isItemAtIndexVisible(index: number): boolean

Checks if Specified item with index is visible.

on

on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void

A basic method signature to hook an event listener (shortcut alias to the addEventListener method).

on(event: "itemLoading", callback: (args: ItemEventData) => void, thisArg?: any): void

Raised when a View for the data at the specified index should be created. The result should be returned trough the view property of the event data. Note, that the view property of the event data can be pre-initialized with an old instance of a view, so that it can be reused.

on(event: "itemTap", callback: (args: ItemEventData) => void, thisArg?: any): void

Raised when an item inside the ListView is tapped.

on(event: "loadMoreItems", callback: (args: EventData) => void, thisArg?: any): void

Raised when the ListView is scrolled so that its last item is visible.

refresh

Forces the ListView to reload all its items.

scrollToIndex

scrollToIndex(index: number): any

Scrolls the specified item with index into view. [iOS](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableView_Class/#//apple_ref/occ/instm/UITableView/scrollToRowAtIndexPath:atScrollPosition:animated:) [Android](http://developer.android.com/reference/android/widget/ListView.html#setSelection(int))

scrollToIndexAnimated

scrollToIndexAnimated(index: number): any

Scrolls the specified item with index into view with animation. [iOS](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableView_Class/#//apple_ref/occ/instm/UITableView/scrollToRowAtIndexPath:atScrollPosition:animated:) [Android](https://developer.android.com/reference/android/widget/ListView.html#smoothScrollToPosition(int))

Previous
ListPicker

Next
ModalTransition