DylanCaiCoding / LoadingStateView

Decoupling the code of toolbar or loading status view. (深度解耦标题栏,解耦加载中、加载失败、无数据等缺省页,支持两行代码集成到基类)
Apache License 2.0
674 stars 53 forks source link

如果使用FragmentContainerView 在fragment添加View时回报错 #22

Closed yudu233 closed 2 years ago

yudu233 commented 3 years ago

Views added to a FragmentContainerView must be associated with a Fragment

请问这样该如何添加

DylanCaiCoding commented 3 years ago

不会意思现在才看到,GitHub 的通知怪怪的,有时会不通知。请问解决了吗?没有的话发 onCreateView 的代码看一下。

yudu233 commented 3 years ago

我差资料说明是: FragmentContainerView只允许由Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)返回的view。试图添加任何其他视图将导致IllegalStateException。

onCreateView 里也没有别的代码 就那俩行添加view的代码

DylanCaiCoding commented 3 years ago

需要在 onCreateView 返回 loadingHelper.decorView,代码如下:

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
  val view = layoutInflater.inflate(R.layout.fragment_home, container, false)
  loadingHelper = LoadingHelper(view)
  return loadingHelper.decorView
}