2
I need to use a component TextSwitcher with the intention that when the user moves this TextSwitcher to the right as well as to the left the text of the same.
For this I created a variable of type String[] and stored 5 values, and used the event OnTouch on the type component TextSwitcher, but with the following code I will post below the text is not exchanged, remains the same, until give an error of ArrayOfBounds because I didn’t handle the size of the Strings array.
What would be the best way to exchange texts?
    tsIntroduction.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getActionMasked()) {
            case MotionEvent.ACTION_DOWN:
                // Variaveis declaradas no topo da aplicação
                initialX = event.getX();
                initialY = event.getY();
            case MotionEvent.ACTION_UP:
                float finalX = event.getX();
                float finalY = event.getY();
                if (initialX < finalX) {
                    pos =+ 1;
                }
                if (initialX > finalX) {
                    pos =- 1;
                }
            }
            // Varíavel pos declarada no inicio da aplicação para pegar a posição atual
            tsIntroduction.setText(descriptions[pos]);
            return true;
        }