https://kotlinlang.org logo
#android
Title
# android
o

o.semen

03/30/2018, 1:05 PM
so I figured out that at runtime
toolbarLayout
is toolbar I’m looking for but it is a
View
as included might be any view… but how can I get it as
Toolbar
without casting ?
l

leosan

03/30/2018, 1:13 PM
just to be sure…, you’re using
setSupportActionBar(toolbarWidget)
but your layout is not a
android.support.v7.widget.Toolbar
is that correct?
o

o.semen

03/30/2018, 1:23 PM
it is
android.support.v7.widget.Toolbar
but it is in separate layout xml file and than included in main layout file.
<include>
tag and
Toolbar
has different ids. I can get my Toolbar by id of
<include>
tag but it is available as a
View
. So I’m looking for a way to get my
Toolbar
, probably by it’s id (specified in separate layout file)
l

leosan

03/30/2018, 1:28 PM
you shouldn’t use the <include> id
I have the exact same case as you doing and I use the toolbar id without any problem, my imports are different though
Copy code
import kotlinx.android.synthetic.main.activity_home.*
import kotlinx.android.synthetic.main.content_home.*
import kotlinx.android.synthetic.main.toolbar.*
I’m not importing using
toolbar.view.*
instead
toolbar.*
2 Views