mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
scrollToIndex added to ListView
This commit is contained in:
@@ -101,6 +101,10 @@ export class ListView extends view.View implements definition.ListView {
|
||||
//
|
||||
}
|
||||
|
||||
public scrollToIndex(index: number) {
|
||||
//
|
||||
}
|
||||
|
||||
public _getItemTemplateContent(index: number): view.View {
|
||||
var v;
|
||||
|
||||
|
||||
@@ -102,6 +102,12 @@ export class ListView extends common.ListView {
|
||||
(<ListViewAdapter>this.android.getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public scrollToIndex(index: number) {
|
||||
if (this._android) {
|
||||
this._android.smoothScrollToPosition(index, );
|
||||
}
|
||||
}
|
||||
|
||||
public _onDetached(force?: boolean) {
|
||||
super._onDetached(force);
|
||||
|
||||
|
||||
8
ui/list-view/list-view.d.ts
vendored
8
ui/list-view/list-view.d.ts
vendored
@@ -85,6 +85,14 @@ declare module "ui/list-view" {
|
||||
*/
|
||||
refresh();
|
||||
|
||||
/**
|
||||
* 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))
|
||||
* @param index - Item index.
|
||||
*/
|
||||
scrollToIndex(index: number);
|
||||
|
||||
/**
|
||||
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
|
||||
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
|
||||
|
||||
@@ -173,6 +173,13 @@ export class ListView extends common.ListView {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
public scrollToIndex(index: number) {
|
||||
if (this._ios) {
|
||||
this._ios.scrollToRowAtIndexPathAtScrollPositionAnimated(NSIndexPath.indexPathForItemInSection(index, 0),
|
||||
UITableViewScrollPosition.UITableViewScrollPositionTop, true);
|
||||
}
|
||||
}
|
||||
|
||||
public refresh() {
|
||||
if (this.isLoaded) {
|
||||
this._ios.reloadData();
|
||||
|
||||
Reference in New Issue
Block a user