Search code examples
androidkotlinkotlin-extension

findViewById ClassCastExcpetion


I'm using the kotlin-extension plugin for finding the views.

But now I get an exception by

setSupportActionBar(mainActivity_toolbar)

It worked until now, but now it gives an

ClassCastException: android.widget.FrameLayout cannot be cast to android.support.v7.widget.Toolbar

The last Thing I did, was to add an id to my fab and set an OnClickListener.

But in my layout.xml:

android.support.v7.widget.Toolbar has the id "@+id/mainActivity_toolbar" and FrameLayout has the id "@+id/mainActivity_framelayout".

I first thought there is a bug in the kotlin-extension plugin, but with findViewById it doesn't work either.

Thank you


Solution

  • Restarting IntelliJ solved my problem.

    Didn't thought on that, only rebuilt my Project and that didn't helped.

    Due to this Post, I thought this could be my problem, so because rebuilt dosn't helped, I restartet IntelliJ and it worked.