Posted By

jordmax12 on 03/03/14


Tagged

array iterator


Versions (?)

iterator java


 / Published in: Java
 

Not sure why it's not sequencing, when I run the app it prints out "ShortCourseDesc6" 6 times instead of doing 1,2,3,4,5,6

  1. public void setListData()
  2. {
  3. for (int i = 0; i < 7; i++) {
  4.  
  5. List<String> imageURLArray = new ArrayList<String>();
  6. imageURLArray.add("ShortCourseDesc1");
  7. imageURLArray.add("ShortCourseDesc2");
  8. imageURLArray.add("ShortCourseDesc3");
  9. imageURLArray.add("ShortCourseDesc4");
  10. imageURLArray.add("ShortCourseDesc5");
  11. imageURLArray.add("ShortCourseDesc6");
  12.  
  13. Iterator<String> iter = imageURLArray.iterator();
  14.  
  15. final SpinnerModel sched = new SpinnerModel();
  16.  
  17. /******* Firstly take data in model object ******/
  18. for(int z = 0; iter.hasNext(); z++)
  19. {
  20. sched.setCourseName("Course: " + z);
  21. sched.setImage("image" + z);
  22. sched.setCourseShortDesc(iter.next());
  23. }
  24.  
  25. /******** Take Model Object in ArrayList **********/
  26. CustomListViewValuesArr.add(sched);
  27. }
  28.  
  29. }
  30.  
  31. }

Report this snippet  

You need to login to post a comment.