B
B
byNova2018-05-11 23:26:48
Java
byNova, 2018-05-11 23:26:48

How to bind another string array for TextView in listener?

There is a TextView, when clicked, the following text is displayed. When text with a certain index appears, a list of answer options is displayed (two more TextViews).
The problem is that after clicking on one of the answer options, I cannot define another array of strings for the main TextView, since the array is already defined in the listener.
This is the first application, so the implementation and code may not seem very good.

mMainTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //индексация массива
            mCurrentIndex = (mCurrentIndex + 1) % mainTextArray.meetingTextsArray.length;

             //массив строк с изменением индекса при клике
            int text = mainTextArray.meetingTextsArray[mCurrentIndex].getTextResId();
            mMainTextView.setText(text);
            //при нужном индексе всплывают варианты ответа(ещё 2 textview)
            if(mCurrentIndex == 1) {
                showChoiceButtons(R.string.meeting_left_text, R.string.meeting_right_text,
                        mMainTextView);

                leftChoiceButtonPressed();
            }
        }
    });

}

private void leftChoiceButtonPressed() {

 //первый вариант ответа, затем нужно изменить массив строк для основного
 //textview
    mLeftChoiceTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMainTextView.setText("Тестим");
        }
    });
}

    private void showChoiceButtons(int leftButton, int rightButton, View view) {
    //показать всплывающие варианты ответа
    mLeftChoiceTextView.setVisibility(View.VISIBLE);
    mRightChoiceTextView.setVisibility(View.VISIBLE);
    mLeftChoiceTextView.setText(leftButton);
    mRightChoiceTextView.setText(rightButton);
    view.setClickable(false);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2018-05-12
@red-barbarian

private void leftChoiceButtonPressed() {

 //первый вариант ответа, затем нужно изменить массив строк для основного
 //textview
    mLeftChoiceTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setSomeNewArray();
            mMainTextView.setText("Тестим");
            mMainTextView.setClickable(true)
        }
    });
}

??? do you want it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question