您好我正在开发一个 Android 应用程序,我需要在其中使用可扩展列表。我在网上找到了一个很好的示例代码来使用可扩展列表。所以我根据这段代码来解决我的问题。结果应该类似于我的 iOS 应用程序,您可以在此处查看屏幕截图:http: //postimg.org/image/ej9t50f6t/。我在这种情况下:我的 Map 的键插入到一个数组中,数据插入到 2 个数组中,现在我应该有这种情况:
Map {
key = Episodio 1 29 Giu 2013, value= [14:30, https://lh6.googleusercontent.com/-XSh-9ngYJu4/ThiY-xl2EeI/AAAAAAAABmc/iz04VpL5hOs/s800/realtime.png, Real Time]
key = Episodio 1 29 Giu 2013, value= [16:30, http://tv.zam.it/canali/dmax.png, DMAX]
key = Episodio 2 01 Lug 2013, value= [14:30, https://lh6.googleusercontent.com/-XSh-9ngYJu4/ThiY-xl2EeI/AAAAAAAABmc/iz04VpL5hOs/s800/realtime.png, Real Time]
key = Episodio 2 01 Lug 2013, value= [16:30, http://tv.zam.it/canali/dmax.png, DMAX]
}
所以我写了这段代码:
String[] progrepvis1 = null;
String[] progrepvis2 = null;
for (int i = 0; i < epTime.length; i++) {
if (i % 2 == 0) {
String[] progrepvis1temp = {epTime[i], epChLogo[i], epCh[i]};
progrepvis1 = progrepvis1temp;
} else {
String[] progrepvis2temp = {epTime[i], epChLogo[i], epCh[i]};
progrepvis2 = progrepvis2temp;
}
}
episodeData = new LinkedHashMap<String, List<String>>();
Log.d("GROUP", "" + groupList);
for (String episode : groupList) {
for (int i = 0; i < episodeNumberAndDate.length; i++) {
if (i % 2 == 0 && episode.equals(episodeNumberAndDate[i])) {
loadChild(progrepvis1);
} else {
loadChild(progrepvis2);
}
}
episodeData.put(episode, childList);
}
Log.d("LISTA", "" + episodeData);
}
private void loadChild(String[] episodeData) {
childList = new ArrayList<String>();
for (String episode : episodeData) {
childList.add(episode);
}
}
但是这个片段的结果如下:
Map {
key = Episodio 1 29 Giu 2013, value= [16:30, http://tv.zam.it/canali/dmax.png, DMAX]
key = Episodio 2 01 Lug 2013, value= [16:30, http://tv.zam.it/canali/dmax.png, DMAX]
}
你可以看到我只是重复程序但我不是第一次,我该如何解决这个问题?我希望你能帮助我谢谢