Just what are you trying to achieve? If you're actually wanting a hash map, efficiently populated on class loading, then Streets of Boston's approach won't help you -- nor will aapt.
To do what you actually ask for, you could write an XSLT script to generate the necessary java code. One of the things you'd have to deal with is handling the @+id/string0 stuff. Well, actually that makes no sense at all. I think you mean something like @string/string0? You'd have to make your XSLT script handle your strings.xml other values files, and map to the appropriate strings. That's probably easiest done as a separate step to consolidate them into a single temporary file. In other words, it's not all that hard to create something like this, given a compelling reason. Do you have a compelling reason? Is there a reason to not just read the XML resource and process it at runtime? On Apr 11, 11:48 am, HippoMan <[email protected]> wrote: > In my app, I'd like to define some static resources in an xml file > which can be accessed via a HashMap. I know I can do this at run time > in a manner similar to the one which is described here: > > http://groups.google.com/group/android-developers/browse_thread/threa... > > However, since my HashMap will be a non-changing resource, I'd like to > precompile my xml into a static HashMap in a manner that is similar to > how the aapt utility precomplies the data in various xml files into > R.java. Furthermore, I'd like the keys and values to be expandable via > the "@+id/item" convention, as follows ... > > Suppose the following items exist in strings.xml: > > <string name="string0">foo</string> > <string name="string1">bar</string> > <string name="string2">quack</string> > <string name="string3">oink</string> > > Then, I would like to be able to do something like this in order to > specify my static HashMap: > > <?xml version="1.0" encoding="utf-8"?> > <map name="mymap"> > <element name="@+id/string0">foo-item</element> > <element name="abc">@+id/string1</element> > <element name="@+id/string2">@+id/string3</element> > </map> > > The resulting generated code in R.java would look something like this: > > public static final class map { > public static final Map<String , String> mymap = new > ConcurrentHashMap<String , String>() {{ > put("foo", "foo-item"); > put("abc", "bar"); > put("quack", "oink"); > }}; > > } > > Is there a way to do anything even remotely similar to this under > Android, perhaps using aadb? > > Or am I out of luck? > > Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.

