我想使用indexOf(),但它无法正常工作。
List<String> datume = new ArrayList<>();
for(int i = 0; i < datumes.length(); i++){
datume.add(datumes.getJSONObject(i).getString("Datum"));
}
java.util.Collections.sort(datume);
看起来像这样:
[1468281600, 1468195200, 1468022400, 1467936000, 1467849600, 1467763200, 1467676800, 1467590400, 1468368000, 1468454400, 1468540800]
但每次它只返回 0,当我搜索这个时:
1467590400
与...
pos = datume.indexOf(preferences.getString("auswahldatum", "n"));
(首选项正常工作)
最佳答案
这实际上正在正常工作。您正在对 ArrayList
进行排序,值 1467590400
作为其中最小的值,占据第一个位置(索引为 0)在新的排序列表中。
关于java - indexOf() - 列表 - Android - 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37707910/