Android如何使用listviews浏览xml文件

时间:2021-12-15 13:30:31

I have a two part question concerning Android. The first, is if I have an xml file which comes prepackaged with the Android app containing modular data, where in the app should I host it? I've seen references to the assets folder, and I've seen references to res/xml. This xml file won't be modified in and of itself, its read only, but it WILL be encrypted when its packaged, so will have to be decrypted by the app.

我有两个关于Android的问题。第一个,如果我有一个xml文件预先包装了包含模块化数据的Android应用程序,应用程序应该在哪里托管它?我已经看到了对assets文件夹的引用,并且我看到了对res / xml的引用。这个xml文件本身不会被修改,它只读,但它在打包时会被加密,因此必须由应用程序解密。

The second part of the question is, once I have the xml in the directory it will live in, how do I open it and parse its contents into a list view? The goal is to have the listviews sort of generate from the nodes of the xml. Meaning, the root node would generate the first options in the list view. As you click on the items corresponding with the nodes, a new listview will be generated based on what that subnode contains. Its basically using listviews to browse through an xml file.

问题的第二部分是,一旦我将xml存放在目录中,我该如何打开它并将其内容解析为列表视图?目标是使列表视图从xml的节点生成。意思是,根节点将在列表视图中生成第一个选项。当您单击与节点对应的项目时,将根据该子节点包含的内容生成新的列表视图。它基本上使用listviews来浏览xml文件。

Thanks for your help! I am sort of new to Android and Java so please don't assume I know that much :)

谢谢你的帮助!我是Android和Java的新手,所以请不要认为我知道那么多:)

1 个解决方案

#1


0  

  1. Store it in Assets folder.
  2. 将其存储在Assets文件夹中。

  3. There are 2 parsers commonly used in Android. You can use both of them. One of the best tutorials. Tutorial uses data from remote source, but you can slightly modify it to use local file.
  4. Android中常用2个解析器。您可以同时使用它们。最好的教程之一。教程使用来自远程源的数据,但您可以稍微修改它以使用本地文件。

#1


0  

  1. Store it in Assets folder.
  2. 将其存储在Assets文件夹中。

  3. There are 2 parsers commonly used in Android. You can use both of them. One of the best tutorials. Tutorial uses data from remote source, but you can slightly modify it to use local file.
  4. Android中常用2个解析器。您可以同时使用它们。最好的教程之一。教程使用来自远程源的数据,但您可以稍微修改它以使用本地文件。