Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Jonathan GrieveTreehouse Moderator 91,250 Points
Error message with Views
After hacvng downloaded a patch to Build 3 of Android Studio it looks like Kotlin as gone back to the original way of assigning views to Variables?
//assign views factsTextView = findViewById(R.id.factsTextView) as TextView showFactsButton = findViewById(R.id.showFactsButton) as Button relativeLayout = findViewById(R.id.relativeLayout) as RelativeLayout
causes the following error for each line
Error:(34, 30) Type inference failed: Not enough information to infer parameter T in fun <T : View!> findViewById(p0: Int): T!
Please specify it explicitly.
Which i've fixed by removing the
as keyword from the declarations.
//assign views factsTextView = findViewById(R.id.factsTextView) showFactsButton = findViewById(R.id.showFactsButton) relativeLayout = findViewById(R.id.relativeLayout)
does this make sense? I'm now using 3.0 RC2. :)