不能直接用id的原因,是因为你的xml没有载入,会导致使用id的时候会报空指针,如果需要使用,在onCreateView return view后,在onViewCreate函数中使用Id直接调用,onViewCreate会在onCreateView后执行
kotlin在fragment中不能像activity中直接通过id调用控件的解决方法
最新推荐文章于 2022-05-17 14:45:25 发布
不能直接用id的原因,是因为你的xml没有载入,会导致使用id的时候会报空指针,如果需要使用,在onCreateView return view后,在onViewCreate函数中使用Id直接调用,onViewCreate会在onCreateView后执行