Skip to content

Commit c0d3a40

Browse files
Hristo HristovHristo Hristov
authored andcommitted
Fix ListView itemClick for android
1 parent a416fa4 commit c0d3a40

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tns-core-modules/ui/list-view/list-view.android.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,10 @@ export class ListView extends ListViewBase {
5656

5757
const listView = new android.widget.ListView(this._context);
5858
listView.setDescendantFocusability(android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS);
59-
this.updateEffectiveRowHeight();
6059

6160
// Fixes issue with black random black items when scrolling
6261
listView.setCacheColorHint(android.graphics.Color.TRANSPARENT);
6362

64-
// listView.setId(this._androidViewId);
65-
6663
ensureListViewAdapterClass();
6764
const adapter = new ListViewAdapterClass(this);
6865
listView.setAdapter(adapter);
@@ -77,6 +74,8 @@ export class ListView extends ListViewBase {
7774

7875
public initNativeView(): void {
7976
super.initNativeView();
77+
this.updateEffectiveRowHeight();
78+
8079
const nativeView: any = this.nativeViewProtected;
8180
(<any>nativeView).itemClickListener.owner = this;
8281
const adapter = (<any>nativeView).adapter;
@@ -97,6 +96,12 @@ export class ListView extends ListViewBase {
9796
super.disposeNativeView();
9897
}
9998

99+
public onLoaded() {
100+
super.onLoaded();
101+
// Without this call itemClick won't be fired... :(
102+
this.requestLayout();
103+
}
104+
100105
public refresh() {
101106
const nativeView = this.nativeViewProtected;
102107
if (!nativeView || !nativeView.getAdapter()) {

0 commit comments

Comments
 (0)