I’m sure there is a simple solution to this but I’m having a hard time with it. I’m trying to use the setDatePicker method the change the date on my DateDialog but I keep getting an index out of bounds error
solo.clickOnButton(0);
solo.setDatePicker(0, year, month, day);
solo.clickOnButton("Set");
The date picker is created in onCreateDialog method
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case START_DATE_ID:
return new DatePickerDialog(this, bDateSetListener, bYear, bMonth,
bDay);
case END_DATE_ID:
return new DatePickerDialog(this, eDateSetListener, eYear, eMonth,
eDay);
}
return null;
}
The error I keep getting says “invalid index 0, size 0.” I don’t see a way that I can store the DatePickerDialog and just set/get the values either. It appears you just have to keep creating a new one. I’m sure someone has this working though. Thanks for any help.
Now that I’ve been working with robotium a little more I see that the errors that it gives you are not really helpful(or in this case, the real issue). The error that I was getting actually had nothing to do with setting the DatePicker. In my test code I ended on an activity that wasn’t the test case’s starting activity, which works outside of testing. After I noticed this I simply went back to the starting activity and the test past…. The moral of the story is that Robotium errors aren’t very clear and you should look for other things that might be wrong in your application or flow to alleviate the odd errors.