I am new to Android Studio/Java.I have composed a script which creates a TextView
contains a number of lines of information. I want to make each line clickable, to create a Toast dialog for example, which content relevant to that entry. This I can do.
I also want the TextView
to be scrollable. I can do this too...... but NOT both.
I am guessing from what I have read that one command cancels the other. Here is the code I am trying to use. Is there another way to enable this?
responseTextView.setMovementMethod(new ScrollingMovementMethod());
responseTextView.setMovementMethod(LinkMovementMethod.getInstance());
responseTextView.setText(builder, TextView.BufferType.SPANNABLE);
I have found the answer by changing the activity_main.xml to place the TextView inside a ScrollView control.
<ScrollView android:visibility="visible"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:keepScreenOn="true"
android:scrollbarStyle="insideInset"
android:id="@+id/scrollView1"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnSearch" >
<TextView
android:id="@+id/lblOutput"
android:isScrollContainer="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:text="Awaiting Results..."
android:verticalScrollbarPosition="right"
android:layout_gravity="top"
android:keepScreenOn="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnSearch" />
</ScrollView>