Home » Android » Value Random in Android Studio-Exceptionshub

Value Random in Android Studio-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

I am making a code that emits random sounds of an array with a button, by pressing a second time as I do so that the value of the array changes to the remaining sounds, my array is of three sounds. Then I leave my code.

 Integer [] sonidos_numbers = {0,1,2};

    Random r = new Random();
    int start = 0;
    int end = 3;
    int playRandom = r.nextInt(end-start) + start;

 btn_Play.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view)
            {
                if (sonidos_numbers[playRandom]==0)
                {
   }
                    });
How to&Answers: