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=" http://schemas.android.com/apk/res/android" ;>
                <gallery title="@string/gallery01" 
thumbnail="@drawable/t_gallery1">
                        <picture thumbnail="@drawable/pic_01">
                        </picture>
                        <picture thumbnail="@drawable/pic_02">
                        </picture>
                        <picture thumbnail="@drawable/pic_03">
                        </picture>
                </gallery>
        </catalog>

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() {
                super.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"
                android:process=":audioplayerservice"
        />

Log

02-27 16:24:04.392: DEBUG/AudioPlayerServiceConnection(8736): Opening
service connection for intent Intent { comp={com.tourizo.android/
com.tourizo.android.services.AudioPlayerService} }
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
ADB
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 {com.tourizo.android/
com.tourizo.android.activities.ChapterActivity}}
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!
  A.

--~--~---------~--~----~------------~-------~--~----~

2. service permissions problem

Hello,

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
android.permission.RECORD_AUDIO
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/
app_name">
          <uses-permission
android:name="android.permission.RECORD_AUDIO" />

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

        <activity android:name=".NALSLMServiceController"
android:label="@string/activity_nalslm_service_controller">
            <intent-filter>
          <uses-permission
android:name="android.permission.RECORD_AUDIO" />
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".NALSLMServiceBinding"
android:label="@string/activity_nalslm_service_binding">
            <intent-filter>
          <uses-permission
android:name="android.permission.RECORD_AUDIO" />
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>

        <activity android:name=".NALSLM"
                  android:label="@string/app_name">
            <intent-filter>
          <uses-permission
android:name="android.permission.RECORD_AUDIO" />
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

--~--~---------~--~----~------------~-------~--~----~

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