如何解决自定义视图问题,如果在同一布局中添加多个自定义视图
在我的项目中,我有一个自定义视图 ExpandableTextView
,它是通过扩展以下布局 widget_expandable_textview
创建的。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:background="@color/appDesignDarkTwo"
style="@style/widgetContainer"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvHeader"
style="@style/textLatoRegularWhite14sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivDropDown"
app:srcCompat="@drawable/ic_down_arrow_blue"
android:padding="@dimen/_5sdp"
app:layout_constraintBottom_toBottomOf="@+id/tvHeader"
app:layout_constraintTop_toTopOf="@+id/tvHeader"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvContent"
style="@style/textLatoRegularWhite2_10sp"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginRight="@dimen/_11sdp"
app:layout_constraintTop_toBottomOf="@+id/tvHeader"
app:layout_constraintLeft_toLeftOf="@+id/tvHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:visibility="gone"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginRight="@dimen/_11sdp"
app:layout_constraintTop_toBottomOf="@+id/tvHeader"
app:layout_constraintLeft_toLeftOf="@+id/tvHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
在 ExpandableTextView
中,我使用
fun setBulletedList(texts: List<String>?){
mIsRecylcerViewContent = true
mView.recyclerView.visibility = View.VISIBLE
var adapter = ExpandableTextViewBulletedTextAdapter()
var layoutManager = LinearLayoutManager(context)
mView.recyclerView.layoutManager = layoutManager
texts?.let {
adapter.setList(texts)
}
mView.recyclerView.adapter = adapter
adapter.notifyDataSetChanged()
}
我在布局中添加了这个ExpandableTextView
<ExpandableTextView
android:id="@+id/ddOfferDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen_10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cvHeaderLayout" />
<ExpandableTextView
android:id="@+id/ddTermsAndConditions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen_10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ddOfferDetails" />
当我从 API 获取报价和条款和条件列表时,从我的片段中,我通过调用 ddOfferDetails.setBulletedList(LIST_OF_OFFER)
将其传递给相应的视图
ddTermsAndConditions.setBulletedList(LIST_OF_TERMS_AND_CONDITIONS)
现在的问题是,在视图中我可以看到条款和条件列表设置为 ddOfferDetails
并且没有任何列表设置为 ddTermsAndConditions
。
我观察到ddOfferDetails
首先显示优惠详情列表,几秒钟后显示条款和条件列表。
如何解决这个问题?
我希望ddOfferDetails
显示优惠详情列表,ddTermsAndConditions
显示条款和条件列表。
请帮忙
提前致谢
干杯
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。