android - 有没有办法在 Kotlin 中继承 Fragment(@LayoutRes contentLayoutId: Int) ?
问题描述
我想制作自定义片段类
抽象类 MyBaseFragment:Fragment()
但是当我继承它时,我得到了太多参数的错误
类 ExampleFragment:MyBaseFragment(R.layout.fragment_example)
有没有办法继承 (@LayoutRes contentLayoutId: Int) 而不是 ()
解决方案
使用以下代码
abstract class MyBaseFragment : Fragment {
constructor() : super()
constructor(@LayoutRes res: Int) : super(res)
}
推荐阅读
- javascript - 使用 lodash 在 javascript 中比较两个深度嵌套的数组
- c# - GeoCoordinateWatcher 的问题 - 一个应用程序的 GeoPositionPermission 被拒绝,但另一个应用程序被授予
- exception - IAR 编译器链接器错误 [Li009]:_CPP_Exceptions 必须被禁用,但模块的值为“已使用”
- python - 检查字典值字典中列表中的值是否并返回索引
- javascript - 如何通过休息电话获得承诺的价值
- amazon-web-services - CreateModel 操作:在 s3://my-bucket/testing/model/output/model.tar.gz 找不到模型数据
- visual-studio - 将 Visual Studio Test Runner 与自定义生成配置一起使用
- java - 用于文本块对齐的 IntelliJ Java 代码样式
- regex - REGEXP_SUBSTR Oracle 不同于 regext.com
- rest - 如何在 Xamarin.Forms 应用程序中组织服务中的 HTTP 响应