选择问题 (list/multilist) codenameone
Selection issue (list/multilist) codenameone
我执行了以下操作以获取以 watchVideo 形式显示的列表中所选项目的 json 值...但是无论如何我也可以获得下一个列表项的值所以我可以在watchVideo形式中设置下一个按钮并直接播放下一个视频...
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);
}
观看视频表格:
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 和源长度进行比较,以避免 NullPointer。
我执行了以下操作以获取以 watchVideo 形式显示的列表中所选项目的 json 值...但是无论如何我也可以获得下一个列表项的值所以我可以在watchVideo形式中设置下一个按钮并直接播放下一个视频...
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);
}
观看视频表格:
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 和源长度进行比较,以避免 NullPointer。