【发布时间】:2013-09-11 17:57:42
【问题描述】:
我有一个数组适配器(字符串),并想将其转换为 List<String>,但经过一番谷歌搜索和几次尝试后,我还没有弄清楚如何做到这一点。
我尝试了以下方法;
for(int i = 0; i < adapter./*what?*/; i++){
//get each item and add it to the list
}
但这不起作用,因为似乎没有 adapter.length 或 adapter.size() 方法或变量。
然后我尝试了这种类型的 for 循环
for (String s: adapter){
//add s to the list
}
但适配器不能在 foreach 循环中使用。
然后我在谷歌上搜索了一个从适配器转换为列表的方法(在数组中),但什么也没找到。
最好的方法是什么?有没有可能?
【问题讨论】:
标签: android arraylist android-arrayadapter