开发者

Defining hierarchy using XML in Android

开发者 https://www.devze.com 2023-02-07 02:38 出处:网络
I want to define a hierarchy as such: Category 1 SubCategory 1.1 SubCategory 1.2 Category 2 SubCategory 2.1

I want to define a hierarchy as such:

Category 1
  SubCategory 1.1
  SubCategory 1.2
Category 2
  SubCategory 2.1

And I would like to do it using Android's XML files (the ones that go inside the "values" folder) and not using code.

In a "regular" XML file I would do something like:

<category>
  <id>1</id>
  <title>Category 1</title>
</category>

<category>
  <id>11</id>
  <title>Category 1.1</title>
  <parent_id>1</pa开发者_C百科rent_id>
</category>

Any suggestions? Thanks.


You should try putting your file in a res/xml/ folder instead of res/values/ and then you can access it like normal XML at runtime with Resources.getXML().

source: http://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes

0

精彩评论

暂无评论...
验证码 换一张
取 消