반응형

E/RecyclerView: No adapter attached; skipping layout

 

위 오류가 뜨고, 리사이클러뷰를 프래그먼트 안에서 사용하고 있다면 코드를 다음과 같이 고쳐보세요.

 

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_schedule, container, false)

        return inflater.inflate(R.layout.fragment_schedule, container, false)
    }

 

위 코드를 아래 코드처럼 변경해주시면 됩니다.

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_schedule, container, false)

        return binding.root
    }

바뀐 것은 맨 마지막 inflater.inflate(~) 부분이 binding.root로 바뀐 것 하나입니다.

반응형

+ Recent posts