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 trialalbert gutierrrez
Courses Plus Student 964 Points..I'M LOST! PLEASE HELP
Hi,just want to ask.. im using android-studio-bundle-141.1903250-windows, im confused in the codes when Ben typed the Drawables: Here are the codes that i wrote from the video. Drawable drawable = getResources().getDrawable(page.getImageId()); mImageView.setImageDrawable(drawable); the getDrawable has a strike through in it and when i hover the pointer ..it says that deprecated.and im getting an error on the text when it is displays on the emulator.. it doesnt take the string that i entered and it just shows "%1$s" on the textfield.. also..i noticed that Ben uses Drawables, but on mine was Mipmap.. are they different ? also in code? thanks ..
2 Answers
John Weland
42,478 PointsDepending on the version of Android Studio you're running Drawables has been deprecated and stuff should go in the folder labeled mipmap. For example where Ben says drawable-mpdi for the folder it would be mipmap-mpdi for the folder name. When he types (R.drawable.fileName) you would use (R.mipmap.fileName). I had this issue as well at first. Let me know if this helped you out.
Juan Ferr
13,220 PointsSame problem as John Welan. I was setting mTextView.setText(pageText); twice
albert gutierrrez
Courses Plus Student 964 Pointsalbert gutierrrez
Courses Plus Student 964 PointsAh i see.. but how about in this code? : Drawable drawable = getResources().getDrawable(page.getImageId()); mImageView.setImageDrawable(drawable); the getDrawable has a strikethrough in it...i'm a bit confused of the R.drawable.fileName to R.mipmap.fileName..how can i change all Drawables to mipmap in this code? thanks for the first answer :D..hope you can help me in this one too
John Weland
42,478 PointsJohn Weland
42,478 PointsAlbert Gutierrrez I am not 100% sure the finer working of it though I can say that yesterday I managed to run some code that was just like this.
In StoryActivity I am still using Drawables as I didn't find a better way to go about it, however in the Story class (model) I am setting to getImageId to a mimmap. The Page class (model) is looking for an id, text, choice1 and choice2 in that order so in the Story class (model) the first parameter its gonna get is my R.mipmap.page#
StoryActivity
Drawable drawable = getResources().getDrawable(mCurrentPage.getImageId());
Page class (model)
Story Class (model)
John Weland
42,478 PointsJohn Weland
42,478 PointsAs far the "%1$s" showing up instead of your name. I had the same problem my problem was these three lines (minus comment line) one of them I forgot to set... I believe it was the last line.
albert gutierrrez
Courses Plus Student 964 Pointsalbert gutierrrez
Courses Plus Student 964 PointsOk..sadly i did what you have told..by still gives me the depracated error and cant return anything.. :(. Maybe I'll try and try until I die to this one and maybe I'll figure it out in the future..anyways.. thank you so much for the help :D.it enlightens my thoughts for the drawables to mipmap, it gave me a bit of understanding..(well in my case though :D). thank you kind sir. Have a blessed day
John Weland
42,478 PointsJohn Weland
42,478 PointsDon't give up. take a break and come back to it. I am new to Android development and thus far when I hit a wall that I can't seem to figure out taking a small break usually helps me come back with a fresh set of eyes. You can do this!
albert gutierrrez
Courses Plus Student 964 Pointsalbert gutierrrez
Courses Plus Student 964 PointsOk thanks for the encouragement. I'll try to fix the code and try to repeat and fully understand the tutorials..and I'll make your answers as reference. Thank you :).