Question

im working on a HelloGallery example for an Android app i'm developing. I need to display two pictures from my res/drawable-hdpi and I'm doing this via the HelloGallery examples on the web. I tried using the HelloViews ( http://developer.android.com/resources/tutorials/views/index.html ) on the Android developers website but apparently they're outdated since the Android 1.5 update. I'm developing my app on 2.1 and res.styleable no longer exists apparently. Then I decided to look in other places and found a really good example on the following website: http://www.androidpeople.com/android-gallery-imageview-example. After making a resources.xml and styles.xml under res/values, it comes up with one error on this part.

TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);

The errors are :

GalleryTheme cannot be resolved or is not a field AND GalleryTheme_android_galleryItemBackground cannot be resolved or is not a field

ANY KIND OF HELP WOULD BE MUCH APPRECIATED as i've been working on this forever. Thanks a lot! Also, a HelloGallery that works and displays the pictures in the res/drawable-hdpi would also be a good alternative / EXTREMELY HELPFUL. THANKS A LOT!

Was it helpful?

Solution

The R class, where your values R.styleable.GalleryTheme and R.styleable.GalleryTheme_android_galleryItemBackground are being retrieved from, contains a class per xml file (kinda)

So for example if you have your GalleryTheme stored in styles.xml you can access it using R.style.GalleryTheme.

Folder R class Drawable R.drawable.* Drawablehdpi R.drawable.* Drawableldpi R.drawable.* Drawablemdpi R.drawable.* Layouts.xml R.layout.* Colours.xml R.colour.*

etc

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top