D
D
dobroduhniy2020-06-08 20:09:41
Java
dobroduhniy, 2020-06-08 20:09:41

How to display elements in order from an array when clicking on images in JAVA?

Greetings. Help solve the problem. When you click on the image, the picture goes to the last one from the array, but you need to go to the next one, and so on in order
with the next clicks.

// Обрабатываем нажаитие на картинку - начало
        shema_centera.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // Условие нажатия на картинку - начало
                if (event.getAction()==MotionEvent.ACTION_DOWN){
                    // если коснулся картинки начало
                    shema_centera.startAnimation(a);
                }else if(event.getAction()==MotionEvent.ACTION_UP){
                    // если отпустил палец начало
                    for(int i = 0; i < array.images1.length; i++) {
                        shema_centera.setImageResource(array.images1[i]);
                         text_lvl.setText(array.texts1[i]);

                        shema_centera.setEnabled(true);
                    }
                }
                // Условие нажатия на картинку - конец
                 return true;
            }
        });
        // Обрабатываем нажаитие на картинку - конец

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question