android - 在某些设备中未显示完整的列表项
问题描述
这就是问题
这是必须的
某些设备(例如华为 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:更多细节,更多细节,更多细节,更多细节,更多细节,更多细节,更多细节,更多细节,更多细节,更多细节
解决方案
推荐阅读
- exception - mret 不返回电脑
- java - 为什么是resultSet.getInt(1); 在下面的代码中有必要吗?
- pine-script - 策略 - 在特定条件下扩大和缩小多个订单
- bash - 如何在命名管道中使用文件命令
- python - 我如何在用另一个脚本 Tkinter 编写的框架中显示小部件
- php - Laravel 异步调用函数
- javascript - Apps Scripts 和 Google Natural Language API 上的循环功能
- android - 空对象引用上的“java.lang.String com.google.firebase.auth.FirebaseUser.getEmail()”
- python - 如何使用邻接矩阵确定从一个节点到另一个节点的所有路由?
- java - 检查一个值是否存在于 Android 的子 Firebase 数据库中