How to use drawable resource in custom XML?

by Robi » Thu, 10 Sep 2009 06:14:58 GMT

Sponsored Links
 Hey guys,

so I have an XML file: xml/catalog.xml
which contains gallery and pictures.

Like this:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
        <catalog xmlns:myres="" ;>
                <gallery title="@string/gallery01" 
                        <picture thumbnail="@drawable/pic_01">
                        <picture thumbnail="@drawable/pic_02">
                        <picture thumbnail="@drawable/pic_03">

In my view I can extract the attribute values using getAttributeValue
() in XmlPullParser, and the result is a string.
But could I somehow get the drawable resource right away? (That's why
I put the @ in the beginning)

getAttributeNameResource() gives null so that ain't good.

Any ideas?


Other Threads

1. Weird problem with connecting to a service

I'm trying to connect to a service, but for some reason connection's
onServiceConnected() never gets invoked with no other errors. It's not
the only service I have and they work fine. Even more. This one was
working before as well, but after adding other services to application
it stopped working. I'm probably doing something wrong, but can't find
any problems...

Debug output below shows that:
1. bindService was invoked.
2. AudioPlayerService was created.
3. AudioPlayerService.onBind() method was invoked.
4. But connection never received call to onServiceConnected() and as a
result never obtained remote interface.

Here's onCreate and onBind methods that shows there's nothing that can
slow them down.

        public void onCreate() {
                Log.d(getClass().getSimpleName(), "Created");

        public IBinder onBind(Intent intent) {
                Log.d(getClass().getSimpleName(), "Binding");
                return _audioPlayerRemoteInterface;

Service configuration

        <service android:name=".services.AudioPlayerService"


02-27 16:24:04.392: DEBUG/AudioPlayerServiceConnection(8736): Opening
service connection for intent Intent { comp={} }
02-27 16:24:04.563: DEBUG/AudioPlayerService(8776): Created
02-27 16:24:04.573: DEBUG/AudioPlayerService(8776): Binding
02-27 16:24:04.592: INFO/jdwp(8776): received file descriptor 26 from
02-27 16:24:12.682: WARN/ActivityManager(47): Launch timeout has
expired, giving up wake lock!
02-27 16:24:12.695: WARN/ActivityManager(47): Activity idle timeout
for HistoryRecord{435024a8 {}}
02-27 16:24:24.393: DEBUG/AndroidRuntime(8736): Shutting down VM

Could you please help me? Am I doing something wrong?

Thank you in advance!


2. service permissions problem


I have a service which uses the RECORD_AUDIO permission.

I have set up my androidmanifest.xml file as I would expect to enable
that permissions (it is included below)

For some reason when I start the service - from the service controller
-  I get the following problem :
W/ServiceManager(   33): Permission failure:
android.permission.RECORD_AUDIO from uid=10024 pid=1887
E/AudioFlinger(   33): Request requires
E/AudioRecord( 1887): AudioFlinger could not create record track,
status: -1

then the service dies !

here is my android manifest file :
   <application android:icon="@drawable/icon" android:label="@string/
android:name="android.permission.RECORD_AUDIO" />

         <service android:name=".NALSLMService">
android:name="android.permission.RECORD_AUDIO" />

        <activity android:name=".NALSLMServiceController"
android:name="android.permission.RECORD_AUDIO" />
                <action android:name="android.intent.action.MAIN" />
android:name="android.intent.category.LAUNCHER" />

        <activity android:name=".NALSLMServiceBinding"
android:name="android.permission.RECORD_AUDIO" />
                <action android:name="android.intent.action.MAIN" />
android:name="android.intent.category.SAMPLE_CODE" />

        <activity android:name=".NALSLM"
android:name="android.permission.RECORD_AUDIO" />
                <action android:name="android.intent.action.MAIN" />
android:name="android.intent.category.LAUNCHER" />


3. Eclipse Android XML Editor Errors

4. option menus id's

5. system.img how to flash it onto the NAND?

6. Translating App to German?

7. Passing keyevents to the next activity in the stack