From fb52c12f91adec3d5b4ae9622202b3cf47b28de6 Mon Sep 17 00:00:00 2001 From: youzhi92 Date: Wed, 13 Oct 2021 19:33:40 +0800 Subject: [PATCH] issueNo: I4DRLI Description: fix the bug of list component. Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: youzhi92 Change-Id: I0153c94f8319f02d923f5f69ca34c48f412c4748 --- frameworks/src/core/components/list_component.cpp | 5 ++++- frameworks/src/core/components/list_component.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frameworks/src/core/components/list_component.cpp b/frameworks/src/core/components/list_component.cpp index 261148a..f621e62 100755 --- a/frameworks/src/core/components/list_component.cpp +++ b/frameworks/src/core/components/list_component.cpp @@ -138,7 +138,10 @@ void ListComponent::OnViewAttached() adapter_.UpdateContentAlignParam(listParameter); adapter_.SetDirection(list_.GetDirection()); // Step4. add children to list dynamically. - list_.SetAdapter(&adapter_); + if (!hasSetAdaptor_) { + list_.SetAdapter(&adapter_); + hasSetAdaptor_ = true; + } } bool ListComponent::UpdateForView() diff --git a/frameworks/src/core/components/list_component.h b/frameworks/src/core/components/list_component.h index 59db3ad..3245d41 100755 --- a/frameworks/src/core/components/list_component.h +++ b/frameworks/src/core/components/list_component.h @@ -43,6 +43,7 @@ private: UIList list_; ListAdapter adapter_; ListEventListener listEventListener_; + bool hasSetAdaptor_ = false; static const char * const FUNC_SCROLLTO; static const char * const INDEX_SCROLLTO; static JSValue ListScrollTo(const JSValue func, const JSValue dom, const JSValue args[], const jerry_length_t size);