mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix ListView itemClick for android
This commit is contained in:
@@ -56,13 +56,10 @@ export class ListView extends ListViewBase {
|
||||
|
||||
const listView = new android.widget.ListView(this._context);
|
||||
listView.setDescendantFocusability(android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS);
|
||||
this.updateEffectiveRowHeight();
|
||||
|
||||
// Fixes issue with black random black items when scrolling
|
||||
listView.setCacheColorHint(android.graphics.Color.TRANSPARENT);
|
||||
|
||||
// listView.setId(this._androidViewId);
|
||||
|
||||
ensureListViewAdapterClass();
|
||||
const adapter = new ListViewAdapterClass(this);
|
||||
listView.setAdapter(adapter);
|
||||
@@ -77,6 +74,8 @@ export class ListView extends ListViewBase {
|
||||
|
||||
public initNativeView(): void {
|
||||
super.initNativeView();
|
||||
this.updateEffectiveRowHeight();
|
||||
|
||||
const nativeView: any = this.nativeViewProtected;
|
||||
(<any>nativeView).itemClickListener.owner = this;
|
||||
const adapter = (<any>nativeView).adapter;
|
||||
@@ -97,6 +96,12 @@ export class ListView extends ListViewBase {
|
||||
super.disposeNativeView();
|
||||
}
|
||||
|
||||
public onLoaded() {
|
||||
super.onLoaded();
|
||||
// Without this call itemClick won't be fired... :(
|
||||
this.requestLayout();
|
||||
}
|
||||
|
||||
public refresh() {
|
||||
const nativeView = this.nativeViewProtected;
|
||||
if (!nativeView || !nativeView.getAdapter()) {
|
||||
|
||||
Reference in New Issue
Block a user