首页 > 解决方案 > 在某些设备中未显示完整的列表项

问题描述

这就是问题

问题截图

这是必须的

结果截图

某些设备(例如华为 gr5 2017)有物品问题。列表的数据从 file.txt 解析,我从 FireBaseStorage 得到。

这是我的适配器

public ChatStoryAdapter(List<ChatMessage> messages, List<UselessClass> uselessClasses, Context context) {
    this.messages = messages;
    this.context = context;
    for (int j = 0; j <= uselessClasses.size(); j++) {
        getShowingMessages().add(messages.get(j));
    }
    i = uselessClasses.size() + 1;
    speaker = getMessages().get(0).getSenderName();
}


@Override
public ChatStoryAdapter.UserListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.chat_massege, parent, false);
    ChatStoryAdapter.UserListViewHolder pvh = new ChatStoryAdapter.UserListViewHolder(v);
    return pvh;
}

@SuppressLint("ResourceAsColor")
@Override
public void onBindViewHolder(ChatStoryAdapter.UserListViewHolder holder, final int position) {
    setColor(holder.speakerName, getShowingMessages().get(position));
    holder.message.setText(getShowingMessages().get(position).getMessageText());
    holder.speakerName.setText(getShowingMessages().get(position).getSenderName());
    if (getShowingMessages().get(position).getImageUrl() != null) {
        Picasso.with(context).load(getShowingMessages().get(position).getImageUrl()).transform(new RoundedTransformation(20, 0)).resize(1200, 800).centerCrop().into(holder.imageView);
    }else {
        holder.imageView.setImageBitmap(null);
    }

public void showOneMore() {
    getShowingMessages().add(getMessages().get(i));
    notifyItemInserted(i);
    i++;
}

用于聊天消息的 XML

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/chat_story"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp">


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toStartOf="@+id/speaker_tv"
        android:background="@drawable/cloud_massege"
        android:orientation="vertical">
    <TextView
        android:id="@+id/message_text"
        style="@style/chat_text_message_style"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:autoLink="web"
        android:textColor="#fff"
        android:maxWidth="280dp"
        android:paddingLeft="20dp"
        android:text="Rahul Agrawal is a good boy but he does not know what he wants."
        android:textDirection="anyRtl"
        tools:targetApi="jelly_bean_mr1" />
        <com.nadera.story.chat.adapters.SquareImageView
            android:id="@+id/image_message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="10dp"
             />
    </LinearLayout>

    <TextView
        android:id="@+id/speaker_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="20dp"
        android:paddingRight="8dp"
        android:paddingTop="5dp"
        android:layout_alignParentRight="true"
        android:text="User1"
        android:textDirection="anyRtl"
        android:textSize="16sp"
        android:textStyle="bold"
        tools:targetApi="jelly_bean_mr1" />
</RelativeLayout>

忽略下一个PLZ:更多细节,更多细节,更多细节,更多细节,更多细节,更多细节,更多细节,更多细节,更多细节,更多细节

标签: android

解决方案


推荐阅读