0

I've been working on an app for a project I'm doing and I started Kotlin a couple of weeks ago for it. I'm trying to display Information from a MySQL database to two RecyclerView split in even and odd columns with the help of NodeJS API . But obviously it gives me E/RecyclerView: No adapter attached; skipping layout two times because of the two RecyclerViews the code is in a github repo - https://github.com/C-Min-Min/Electry-Android-App The main part is : the page the RecyclerViews are in the app under - layout/fragment_devices.xml with java/fragments/DevicesFragment.kt the API to fetch the information for the app is under - java/API/ with the Adapters java/Adapter/ the NodeJS api is outside of the Android app folder and you can run with node index.js in your command prompt the database is outside of any folder it's called electry.sql

If anyone wants to take a look or has an idea on how to solve it please help thank you in advance

If you want to see any part of the code but don't want to open the repo ask I will give it

TechX
  • 77
  • 1
  • 11
  • Apart from that message in the log, is it working? You get that error in the log when the first layout pass happens and you haven't set an adapter on the ``RecyclerView`` yet, it's not really a problem. You could just create and set a pair of empty throwaway adapters in ``onCreate`` if you want to test it - if it's still not displaying, you've got a problem with your code that updates the lists – cactustictacs Aug 03 '21 at 19:27
  • @cactustictacs I think it's possible that the it's not assigning the adapter because it's in a fragment, I tried with hard coded values for the recyclerview but it still doesn't display anything – TechX Aug 04 '21 at 10:04

1 Answers1

0

Found the solution myself : Since my recyclerviews were in a fragment the adapter connection in the fragment's kotlin file had to be different and not in onCreate but in onCreateView:

override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        // Inflate the layout for this fragment
        val view:View = inflater.inflate(R.layout.fragment_devices,container,false)

        val recyclerView = view.findViewById<RecyclerView>(R.id.odd_list)
        oddDevices = OddDevices.createOddDeviceList(5)

        val adapter = OddDeviceAdapter(oddDevices)

        //recyclerView.hasFixedSize(true)
        recyclerView.layoutManager = LinearLayoutManager(view.context)
        recyclerView.adapter = adapter

        return view
    }
TechX
  • 77
  • 1
  • 11