I want to create an app on that the idea is click on the button and changing an image. every time I click on the button an imageview change (dynamic imageview). I'm trying to do that but when I run the code below the first imageview is loaded and when I press the button, the first imageview jump to last imageview, ignoring two imageviews among them. What's wrong? 

This is my code:

```
 SEGUNDATELA. JAVA:

       public class SegundaTela extends AppCompatActivity {
        private Integer [] imagens = new Integer[]{R.drawable.tabeladia2, R.drawable.tabeladia3, R.drawable.tabeladia4, R.drawable.tabeladia5};
        private RadioGroup radioGroup;
        private RadioButton sim;
        private RadioButton nao;
        private Button proxima;
        private ImageView img;
        private int i=0;
        private Integer [] dados= new Integer[4];
        private int soma =0;
        private int j;
        private int inicio;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_segunda_tela);

            img = findViewById(R.id.imageView);
            proxima = findViewById(R.id.proximaId);
            radioGroup = findViewById(R.id.RadioGroupId);
            sim = findViewById(R.id.simId);
            nao = findViewById(R.id.naoId);

            if (sim.isChecked()) {
                inicio = 1;
            } else if (nao.isChecked()) {
                inicio = 0;
            }

            proxima.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    if (i < 4) {
                        ++i;
                        j = (i - 1);

                        switch (j) {

                            case 0:

                                if (sim.isChecked()) {
                                    img.setImageResource(imagens[j]);
                                    dados[j] = 2;

                                } else if (nao.isChecked()) {
                                    img.setImageResource(imagens[j]);
                                    dados[j] = 0;
                                }
                                break;
                            case 1:

                                if (sim.isChecked()) {
                                    img.setImageResource(imagens[j]);
                                    dados[j] = 4;

                                } else if (nao.isChecked()) {
                                    img.setImageResource(imagens[j]);
                                    dados[j] = 0;
                                }
                                break;
                            case 2:

                                if (sim.isChecked()) {
                                    img.setImageResource(imagens[j]);
                                    dados[j] = 8;

                                } else if (nao.isChecked()) {
                                    img.setImageResource(imagens[j]);
                                    dados[j] = 0;
                                }
                                break;
                            case 3:

                                if (sim.isChecked()) {
                                    img.setImageResource(imagens[j]);
                                    dados[j] = 16;

                                } else if (nao.isChecked()) {
                                    img.setImageResource(imagens[j]);
                                    dados[j] = 0;
                                }
                                break;

                        }
                        radioGroup.clearCheck();

                    } else {
                        soma = dados[0] + dados[1] + dados[2] + dados[3] + inicio;
                        Intent i = new Intent(SegundaTela.this, MainActivity.class);
                        i.putExtra("soma", soma);
                        startActivity(i);
                    }
                }

            });

        }
        }

SEGUNDATELA.MML

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/proximaId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="8dp"
        android:text="proxima"
        app:layout_constraintBottom_toTopOf="@+id/imageView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        android:scaleType="fitXY"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/tabeladia1" />

    <RadioGroup
        android:id="@+id/RadioGroupId"
        android:layout_width="98dp"
        android:layout_height="86dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toTopOf="@+id/imageView"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <RadioButton
            android:id="@+id/simId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Sim" />

        <RadioButton
            android:id="@+id/naoId"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Não" />
    </RadioGroup>

```