Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid TextView doesn't update its text when textIsSelectable is set to true
    primarykey
    data
    text
    <p>I faced this strange problem that caused me a lot of headache and trouble.</p> <p>I published an application that is a repository of several books, I decided to use TextView to display the text of each chapter because it fits the requirements and it is fast and easy to be used.</p> <p>The user asked that he could select a text and copy it, I used textIsSelectable = true and everything was fine, next day he called me to report that the text in not changing, you open a chapter and you switch to another chapter but the text remains the same.</p> <p>I thought it might be some logical problem from my side, but after some debugging the problem was in TextView, when I set textIsSelectable = false; everything was fine.</p> <p>To be sure I used a static int that is increased each time the text is displayed, the text remained unchanged.</p> <p>So what is the problem? am I using TextView the wrong way? or it is some bug in the TextView itself?</p> <p>Here's my layout (txtBody is the TextView that causes the problem)</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"&gt; &lt;ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/scrollView" android:fillViewport="true" &gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="right"&gt; &lt;TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Title Text" android:id="@+id/txtTitle" android:textSize="24sp" android:padding="5dp" android:gravity="right"/&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Detail Text" android:id="@+id/txtBody" android:background="@android:color/white" android:gravity="right" android:textColor="@android:color/black" android:textSize="16sp" android:padding="5dp" android:enabled="true" android:textIsSelectable="true" android:selectAllOnFocus="false" android:soundEffectsEnabled="true"/&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; &lt;/FrameLayout&gt; </code></pre> <p>I use this code to set the text:</p> <pre><code>String body = MainDataManager.getInstance().getChapterBody(book.getTable(), chapter.getId()); updateTextStyle(); txtTitle.setText(chapter.getTitle()); txtBody.setText(body, TextView.BufferType.SPANNABLE); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload