java - 如何在android中的字符串中存储迭代器值

标签 java android iterator

在我的应用程序中,当我单击按钮时,它会命中 URL 并返回 xml 文件。从该 xml 文件中,我使用 dom 解析器和迭代器列出了特定标签。使用以下代码,我列出了 logcat 中的数据。

Iterator<String> itr = arl.listIterator();
            int z=0,x=0,increment=0;
            while (itr.hasNext()) 
            {
                Log.e("ViewImage5-list all  "+z, itr.next());
                z++;
            }

现在我在 logcat 中得到的所有值我想将这些值存储在数组字符串中。如何储存它。请用代码解释一下......

最佳答案

试试这个:

Iterator<String> itr = arl.listIterator();
            int z=0,x=0,increment=0;
            List<String> strings = new ArrayList<String>();
            while (itr.hasNext()) 
            {
                String data = itr.next();
                list.add(data);
                Log.e("ViewImage5-list all  "+z, data);
                z++;
            }
            // the list "strings" now holds all your strings

关于java - 如何在android中的字符串中存储迭代器值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6044104/

相关文章:

python - 迭代器失效的规则是什么?

c++ - 带有 STL 映射和列表的指针

Java 正则表达式 : Replace all characters with `+` except instances of a given string

java - 我需要在另一个 Activity 中复制我的数组列表

android - Sip 到 WebRTC 调用

java - GridView 项目剪裁和不同的高度

iterator - 如何用迭代器包装 asyncio

java - 在play框架2.4中添加新的Mongo模块

java - java.util.Stack.clear() 的性能

java - 将单个可运行对象传递给多个线程构造函数