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);
|
const listView = new android.widget.ListView(this._context);
|
||||||
listView.setDescendantFocusability(android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS);
|
listView.setDescendantFocusability(android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS);
|
||||||
this.updateEffectiveRowHeight();
|
|
||||||
|
|
||||||
// Fixes issue with black random black items when scrolling
|
// Fixes issue with black random black items when scrolling
|
||||||
listView.setCacheColorHint(android.graphics.Color.TRANSPARENT);
|
listView.setCacheColorHint(android.graphics.Color.TRANSPARENT);
|
||||||
|
|
||||||
// listView.setId(this._androidViewId);
|
|
||||||
|
|
||||||
ensureListViewAdapterClass();
|
ensureListViewAdapterClass();
|
||||||
const adapter = new ListViewAdapterClass(this);
|
const adapter = new ListViewAdapterClass(this);
|
||||||
listView.setAdapter(adapter);
|
listView.setAdapter(adapter);
|
||||||
@@ -77,6 +74,8 @@ export class ListView extends ListViewBase {
|
|||||||
|
|
||||||
public initNativeView(): void {
|
public initNativeView(): void {
|
||||||
super.initNativeView();
|
super.initNativeView();
|
||||||
|
this.updateEffectiveRowHeight();
|
||||||
|
|
||||||
const nativeView: any = this.nativeViewProtected;
|
const nativeView: any = this.nativeViewProtected;
|
||||||
(<any>nativeView).itemClickListener.owner = this;
|
(<any>nativeView).itemClickListener.owner = this;
|
||||||
const adapter = (<any>nativeView).adapter;
|
const adapter = (<any>nativeView).adapter;
|
||||||
@@ -97,6 +96,12 @@ export class ListView extends ListViewBase {
|
|||||||
super.disposeNativeView();
|
super.disposeNativeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onLoaded() {
|
||||||
|
super.onLoaded();
|
||||||
|
// Without this call itemClick won't be fired... :(
|
||||||
|
this.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
public refresh() {
|
public refresh() {
|
||||||
const nativeView = this.nativeViewProtected;
|
const nativeView = this.nativeViewProtected;
|
||||||
if (!nativeView || !nativeView.getAdapter()) {
|
if (!nativeView || !nativeView.getAdapter()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user