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! While you're at it, check out some resources Treehouse students have shared here.

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

Android Build an Interactive Story App (Retired) Intents and Multiple Activities Adding a Second Activity

Aleksander Aleksic
Aleksander Aleksic
7,965 Points

Lambda

I see you use Lambda in the onClick method, but when i trie to use it i get an compile error. Any idea ?

2 Answers

Seth Kroger
Seth Kroger
56,413 Points

You can't use lambda's in in Android code just yet, since Android only officially supports Java 7, so far, not 8. So you will need to use one of the other methods like an anonymous inner class, etc.

Now Android Studio does do something called "code folding" where it will simplify the display of the code. Things like showing the string used from the string.xml file in place of R.string.whatever. They'll be highlighted but when you click to edit them they show the actual code. One of the "foldings" is to show an 1-method anonymous inner class in lambda notation instead. You can see in the video at 4:20 where Ben explains what AS is doing there.

Please provide your code and the error log.