-1

I have Problem java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

I have a Spinner with different Number contrat, i choose a contract to display all information of this contract in the same Fragment but i have all the time this error This my code

        if (AareonLocataireManager.getInstance().getMultiContrateModel() != null && AareonLocataireManager.getInstance().getMultiContrateModel().size() > 0) {
        ArrayList<ContratModel> contracts = AareonLocataireManager.getInstance().getMultiContrateModel();
        this.contratModel = contracts.get(1);
        Toast.makeText(getActivity(), ""+this.contratModel.getStationnementBailList().get(1).getADDRESS(), Toast.LENGTH_SHORT).show();

    }

I put number static 1 just to test but i have all the time the same problem

E/AndroidRuntime: FATAL EXCEPTION: main Process: fr.aareon.logismetropole, PID: 18932 java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.get(ArrayList.java:411)

1 Answers1

0

You can only access the contract on position 0 in your List. As the error says your size is 1 so you will have 1 element in the List (starting with position 0).

Rene Ferrari
  • 4,096
  • 3
  • 22
  • 28