Android Is it possible to define a map in an XML file?

前端 未结 4 827
执念已碎
执念已碎 2020-12-14 08:02

I was trying to define a static hash table that makes use of resources, but I got stonewalled by the impossibility of accessing resources statically.

Then I realized

4条回答
  •  情深已故
    2020-12-14 08:56

    How can I define a map in XML?

    
      bar
      baz
      
    
    

    Put this in res/xml/, and load it using getResources().getXml(). Walk the events to build up a HashMap.

提交回复
热议问题