我有一个循环,运行带有2个参数的方法。但是,indexPath参数在if语句之后始终等于0,而不是之前。
ArrayList<RelativeLayout> containers2 = new ArrayList<>();
containers2.add(dayNameContainer);
containers2.add(dayNumberContainer);
containers2.add(monthContainer);
containers2.add(yearContainer);
for (RelativeLayout container : containers2) {
addContainerToView(container, 0);
addContainerToView(container, 1);
addContainerToView(container, 2);
addContainerToView(container, 3);
}
方法:
public void addContainerToView(RelativeLayout container, int indexPath) {
// HERE (BEFORE THE IF STATEMENT) THE INDEXPATH PARAMETER IS CORRECT
if (sharedPreferences.getIntegerValue(container.getTag().toString()) == indexPath) {
// ISSUE HERE CONSTANTLY RECIEVING INDEX PATH AS 0 BUT ONLY AFTER THE IF STATEMENT ABOVE
positioningContainer.addDragView(container, container);
}
}
说实话,我真的不知道还有什么要说的。这似乎很奇怪。