Dear developers. I am writing my first full-fledged application on android, something like a text game. Faced with a little problem.
There is a TextView, when clicked, the following text is displayed. When text with a specific index appears, a list of response options is displayed (two more TextViews).
The problem is that after clicking on one of the answer options I canβt define another array of strings for the main TextView.
Maybe I wrote it in an incomprehensible language, and the code itself is probably not very good, but I will be glad to help. Thank you in advance.
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); } <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" tools:context=".BookActivity" tools:layout_editor_absoluteY="81dp"> <TextView android:id="@+id/main_text" android:layout_width="218dp" android:layout_height="217dp" android:layout_marginEnd="8dp" android:layout_marginStart="8dp" android:layout_marginTop="144dp" android:gravity="center_horizontal|center_vertical" android:textSize="15sp" android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/left_choice_text" android:layout_width="114dp" android:layout_height="113dp" android:layout_marginBottom="16dp" android:layout_marginStart="32dp" android:textSize="15sp" android:textStyle="bold" android:textColor="@color/light" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" /> <TextView android:id="@+id/right_choice_text" android:layout_width="114dp" android:layout_height="113dp" android:layout_marginBottom="16dp" android:layout_marginEnd="32dp" android:textSize="15sp" android:textStyle="bold" android:textColor="@color/light" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" />
mLeftChoiceTextViewwhat next do you want to happen? so that inmMainTextViewwhen clicked, themainTextArray.meetingTextsArrayarraymainTextArray.meetingTextsArraychanged to another? - zayn1991