View.setVisibility(View.Gone) doesn't work anymore
<p>I have a problem. view.setVisibility(View.GONE) doesn't work for me anymore. I will show you what I'm working on.</p>

<p>I globally declared this outside of OnCreate() : </p>

<pre><code>final ArrayList&lt;View&gt; ViewList = new ArrayList&lt;View&gt;();
int CurrentViewId = 0;
int EmployerViewId = 0;
int LastViewId = 0;
</code></pre>

<p>After that I added Views to it in OnCreate() like this: </p>

<pre><code>ViewList.add(findViewById(R.id.content_main_lo));
ViewList.add(findViewById(R.id.data1_lo));
ViewList.add(findViewById(R.id.data2_lo));
</code></pre>

<p>... In total i got 6. </p>

<p>After the Next Button is clicked, the edittexts on each of these layouts should be checked for input. Checkinput returns true if all edittexts are filled in. So if it returns true, the Current View is taken from the Viewlist and made Invisible while the next view in the list will be made visible. </p>

<pre><code>public void OnNextButtonClick(View v) {
    if (CheckInput(v)) {

        ViewList.get(CurrentViewId).setVisibility(View.GONE);
      // ^^This  
        if (v.getId() == R.id.employer_btn)
            CurrentViewId = EmployerViewId;
        else {
            CurrentViewId++;
            if (CurrentViewId == EmployerViewId)
                CurrentViewId = LastViewId;
        }            
        ViewList.get(CurrentViewId).setVisibility(View.VISIBLE);            
    }
}
</code></pre>

<p>Now the result is, even if I filled in all edittexts correctly, and CheckInput actually returns true, the Current View (which is Index 1 in the ViewList, Index 0 works) doesnt get invisible. 
I debugged my program and had a closer look and everything goes as planned, and as it passes the ViewList.get(CurrentViewId).setVisibility(View.GONE); everything keeps working, but the view doesnt disappear on my phone. 
Then i can click the "Next" Button 4 more times, and the app crashes, because OnNextButtonClick works fine and seems to actually load the other Views somehow, but at the 5th time the app crashes because of an IndexOutOfBoundException, since there are only 6 Views in my ViewList and I have clicked the Button before.</p>

<p>Does anybody have an idea the the view just won't disappearing?
The Method OnNextButtonClick works just fine for the previous View (Index 0)</p>

<p>Thanks a lot!</p>

<p>Here is Checkinput if needed: 
I'm basically just find fitting layouts for the pressed NextButton
and i give the fitting layout to Border and return its boolean value</p>

<pre><code>public boolean CheckInput(View v) {
    LinearLayout layout = null;

    if (v.getId() == R.id.employee_btn_1){
        setContentView(R.layout.employee_data1);
        layout = (LinearLayout) findViewById(R.id.employee_lay);
    }
    else if (v.getId() == R.id.employee_btn_2){
        setContentView(R.layout.employee_data2);
        layout = (LinearLayout) findViewById(R.id.employee_lay2);
    } 

    // ... 

    return (Border(layout));
</code></pre>

<p>And here is the Border Method:</p>

<pre><code>public boolean Border(LinearLayout layout) {

    boolean errorfree= true;
    int check = 0;

    if (layout.getChildCount() != 0) {
        for (int i = 0; i &lt; layout.getChildCount(); i++) {
            View view = layout.getChildAt(i);

            if (view instanceof EditText) {
                String input = "";
                EditText edt = (EditText) view;
                if (view.getId() == this.workas_et.getId()) {
                    input = this.workas_et.getText().toString();
                } else if (view.getId() == this.communicate_et.getId()) {
                    input = this.communicate_et.getText().toString();
                } 
                // ...

                if (input.isEmpty()) {
                    edt.setBackgroundResource(R.drawable.border);
                    check++;
                } else {
                    edt.setText(input);

                }
            }
        }
    }
    if (check != 0) {errorfree= false; }
    return errorfree;
}
</code></pre>