简体   繁体   中英

Random dots replacing text in TextViews of items in RecycleView

The picture below shows the problem. There are three dots that randomly seem to replace partial or complete portions of the TextViews for some reason. The three items show below are three of many in a RecycleView.

在此处输入图片说明

However the code that fills the data in the viewholder is the following:

@Override
public void onBindViewHolder(EntryViewHolder holder, int position) {
    if (filteredEntries.size() <= position) return;
    if (position < 0) return;
    String entryName = filteredEntries.get(position);
    Entry e = Aux.appData.getEntry(entryName);
    holder.entryName.setText(entryName);
    System.err.println("ENTRY: " + entryName);
    holder.userName.setText(e.userName);
    holder.iconText.setText(entryName.substring(0,1).toUpperCase());
    holder.passWord.setText(e.passWord);
}

This provides the following output in the logcat:

01-03 16:59:26.436 21962-21962/org.ariela.colocrypter W/System.err: ENTRY: github
01-03 16:59:26.769 21962-21962/org.ariela.colocrypter W/System.err: ENTRY: GoG
01-03 16:59:27.216 21962-21962/org.ariela.colocrypter W/System.err: ENTRY: greenmangaming

Layout is as follows in case this helps:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:paddingBottom="@dimen/padding_list_row"
    android:paddingStart="?listPreferredItemPaddingLeft"
    android:paddingEnd="?listPreferredItemPaddingRight"
    android:background="@drawable/bg_list_row"
    android:paddingTop="@dimen/padding_list_row">

    <LinearLayout
        android:id="@+id/message_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingStart="56dp"
        android:paddingEnd="@dimen/padding_list_row"
        android:focusable="true">

        <TextView
            android:id="@+id/tvEntryName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:lines="1"
            android:textColor="@color/primaryTextColor"
            android:textSize="@dimen/msg_text_primary"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tvDescription"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:lines="1"
            android:textColor="@color/secondaryLightColor"
            android:textSize="@dimen/msg_text_secondary" />

    </LinearLayout>

    <RelativeLayout
        android:id="@+id/icon_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/ivCircle"
            android:layout_width="@dimen/icon_width_height"
            android:layout_height="@dimen/icon_width_height"
            tools:ignore="ContentDescription"
            android:src="@drawable/bg_circle" />

        <TextView
            android:id="@+id/tvLetter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:textColor="@android:color/white"
            android:textSize="@dimen/icon_text" />

    </RelativeLayout>

    <TextView
        android:id="@+id/tvDaysSinceChange"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:textColor="@color/primaryTextColor"
        android:textSize="@dimen/timestamp"
        android:textStyle="bold" />


</RelativeLayout>

So my question is, What is causing this problem?

So here is the thing. I've got three textViews and two of these had problems. The basic code for the layout came from an online example. So I checked the code in each TextView and found that the ones with problems had the following line:

android:ellipsize="end"

Erarsing this line, fixed the problem. According to the documentation:

If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. 

However, it seems to be buggy but it should not have a problem with a three letter word like GoG.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM