[英]I have an arraylist and its size is 1, but when i get at index 0, i get = java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
VideoTask videoTask = new VideoTask(paccakModel, childPosition, video);
videoTask.execute();
ArrayList<VideoModelXml> test = videoTask.getVideoModelXmls();
test.get(0);
video.setVideoPath(test.get(0).getUrlVideo());
video.start();
return true;
}
I have an arraylist and its size is 1, but when i get at index 0, i get = java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 can anybody tell me, what is going on?我有一个数组列表,它的大小是 1,但是当我到达索引 0 时,我得到 = java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 谁能告诉我,这是怎么回事?
The reason for your issue is videoTask.getVideoModelXmls()
returns nothing.您的问题的原因是videoTask.getVideoModelXmls()
不返回任何内容。 It should be empty.它应该是空的。 If you want to avoid the crash如果你想避免崩溃
ArrayList<VideoModelXml> test = videoTask.getVideoModelXmls();
if (test .size() > 0){
test.get(0);
video.setVideoPath(test.get(0).getUrlVideo());
video.start();
}
Which will avoid your crash.这将避免你的崩溃。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.