0

我有一个运行带有 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);
    }
}

老实说,我真的不知道还能说什么。这似乎是非常奇怪的行为。

4

0 回答 0