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) The Model-View-Controller Pattern Creating the Story

fadhil suhendi
fadhil suhendi
7,680 Points

About "mPages[0].setImageId(R.drawable.page0)"

So what does the "R.drawable.page()" return ? cause I know that the method setImageId that we call from Page.java has parameter int, but what does the "R.drawable.page()" return ? I'm a little bit confused here..

thank you!

1 Answer

Ratul Sarna
PLUS
Ratul Sarna
Courses Plus Student 11,618 Points

"R.drawable.page0" is not a method, so it would not return anything. It refers to a static field that exists inside an inner class named "drawable" which itself resides in the R class. This R class is an auto-generated class that creates static fields from the xml layout elements that one defines. It names the fields according to the id attribute one specifies for the xml elements.

Hope that clears it up a bit.