大佬教程收集整理的这篇文章主要介绍了将特定内容添加到空的 LinearLayout 中导致错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想制作用作基本设计的自定义 BottomSheet
布局。它有风格化的标题,然后是空 linearLayout
的内容容器。我想要做的是动态地将自定义内容添加到这个 linearLayout
中。
protected fun setContent(content: VIEwGroup){
bottomSheetParent.findVIEwByID<linearLayout>(R.ID.contentContainer).also {
it.removeAllVIEws()
it.addVIEw(content)
}
}
这与我的自定义 Dialog
布局配合良好,我可以在其中动态地将内容添加到 Dialog
窗口中,但由于某种原因,BottomSheet
会导致异常。
java.lang.IllegalStateException: The specifIEd child already has a parent. You must call removeVIEw() on the child's parent first.
孩子有父母是什么意思?我知道此 BottomSheet
布局的父级具有标题 TextVIEw
和内容容器。从其父项中删除所有 VIEws
将完全破坏空模板。
这是bottomSheetParent
:
<?xml version="1.0" enCoding="utf-8"?>
<linearLayout xmlns:androID="http://scheR_851_11845@as.androID.com/apk/res/androID"
xmlns:app="http://scheR_851_11845@as.androID.com/apk/res-auto"
androID:orIEntation="vertical"
androID:layout_wIDth="match_parent"
androID:layout_height="wrap_content"
app:behavior_hIDeable="true"
app:behavior_peekHeight="0dp"
app:layouT_Behavior="com.Google.androID.material.bottomsheet.bottomSheetBehavior">
<linearLayout
androID:ID="@+ID/title_block"
androID:layout_wIDth="match_parent"
androID:layout_height="wrap_content"
androID:orIEntation="horizontal"
androID:BACkground="@drawable/bg_dialog_top">
<TextVIEw
androID:ID="@+ID/title"
style="@style/dialog_title"
androID:layout_wIDth="match_parent"
androID:layout_height="wrap_content"
androID:text="title"/>
</linearLayout>
<linearLayout
androID:ID="@+ID/bottom_block"
androID:layout_wIDth="match_parent"
androID:layout_height="wrap_content"
androID:orIEntation="vertical"
androID:layout_gravity="center_horizontal"
androID:gravity="center_horizontal"
androID:padding="@dimen/padding_medium"
androID:BACkground="@drawable/bg_dialog_bottom">
<linearLayout
androID:ID="@+ID/contentContainer"
androID:layout_wIDth="match_parent"
androID:layout_height="wrap_content"
androID:orIEntation="vertical"/>
<linearLayout
androID:ID="@+ID/buttonContainer"
androID:layout_wIDth="match_parent"
androID:layout_height="wrap_content"
androID:padding="@dimen/padding_small"
androID:cliPTOPadding="false"
androID:orIEntation="vertical">
</linearLayout>
</linearLayout>
</linearLayout>
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的将特定内容添加到空的 LinearLayout 中导致错误全部内容,希望文章能够帮你解决将特定内容添加到空的 LinearLayout 中导致错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。