我做了以下操作来获取以watchVideo形式显示的列表中所选项目的json值...但是无论如何我都可以获得下一个列表项的值,以便我可以设置下一个手表视频形式的按钮,也直接播放下一个视频...
findYoutubeMultiList(f).setModel(new com.codename1.ui.list.DefaultListModel(mData));
findYoutubeMultiList(f).addActionListener((e) -> {
selection = (Map<String, String>) findYoutubeMultiList(f).getSelectedItem();
indexSelection = findYoutubeMultiList(f).getSelectedIndex();
**//i can get the index of selected item by above indexSelection but how to get the value of the incremented index??**
showForm("WatchVideo", null);
});
编辑:
for (int i = 0; i < response.size(); i++) {
Hashtable hm = (Hashtable) response.get(i);
Hashtable snippet = (Hashtable) hm.get("snippet");
HashMap<String, Object> m = new HashMap<String, Object>();
videoResource = (Hashtable) snippet.get("resourceId");
videoId = videoResource.get("videoId").toString();
m.put("video", videoId);
mData.add(m);
}
WatchVideo表格:
protected void beforeWatchVideo(Form f) {
for (int i = 0; i < mData.size(); i++) {
//how to get the position of selection and more
importantly how to get the values of incremented index
}
答案 0 :(得分:1)
循环遍历多列表的来源并获取所选项目的索引,然后只需递增索引并获取该索引处的值,如果要播放前一个索引则减少。
请记住将索引与0和源长度进行比较以避免NullPointer。