android - 自定义视图出现问题,如果在同一布局中添加多个自定义视图
问题描述
在我的项目中,我有一个自定义视图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
我使用方法将适配器设置为recyclerview
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
显示条款和条件列表。
请帮助
提前谢谢
干杯
解决方案
推荐阅读
- html2canvas - img 标记未使用 html2canvas 特别捕获 png 图像
- vba - 三角锥,三角锥 offset-3d-Plane-Intersection By vbasolver
- docker - 生成带有扩展 ARG 指令的新 Dockerfile
- sql - 试图在 Presto 中以毫秒为单位获取 HH:MM:SS
- ruby - Ruby:Ruby 在哪里记录其错误(错误/异常的位置)?
- logging - 是否可以仅从具有特定标签的 VM 中过滤日志?GCP 云日志记录
- r - 如何粘贴计算机名称作为文件路径
- import - Cryengine 3 Cgf 上传失败
- python - 如何在 odoo 上为发票 pdf taxt 提取创建数据模型?
- python - createView 中的自动完成 slug 字段