gpt4 book ai didi

android - ListView Lollipop 不显示所有信息

转载 作者:行者123 更新时间:2023-11-29 01:29:21 25 4
gpt4 key购买 nike

我有一个 ListView 在某些版本的 android 中工作正常,但在 lollipop 中 ListView 不显示所有信息(只有 1 个字符串,每 5 个字符串)。在我的应用程序中,我只有一个扩展 AppCompatActivity 的 Activity ,这里是我的适配器

    public class PromoAdapter extends ArrayAdapter {


private Context context;
private ArrayList<PromoObject> originalData = null;
public PromoAdapter(Context context, ArrayList<PromoObject> listArray) {
super(context, R.layout.home_promo_item);
this.context = context;
this.originalData = listArray ;
}

public static class Row
{
public TextView labelPromo;
public ImageView imagePromo;
public TextView titlePromo;
public TextView daysPromo;
public TextView schedulePromo;
}

@Override
public int getCount() {
return originalData.size();
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
// reuse views
if (rowView == null) {
LayoutInflater inflater = LayoutInflater.from(context);
rowView = inflater.inflate(R.layout.home_promo_item, null);
// configure view holder
Row viewHolder = new Row();

viewHolder.labelPromo = (TextView) rowView.findViewById(R.id.label_promo);

viewHolder.imagePromo = (ImageView) rowView.findViewById(R.id.logo_promo);

viewHolder.titlePromo = (TextView) rowView.findViewById(R.id.title_promo);

viewHolder.daysPromo = (TextView) rowView.findViewById(R.id.days_promo);

viewHolder.schedulePromo = (TextView) rowView.findViewById(R.id.schedule_promo);

rowView.setTag(viewHolder);
}
Row holder = (Row) rowView.getTag();
PromoObject itm = originalData.get(position);
holder.labelPromo.setText(itm.getPromoValue());
holder.imagePromo.setImageResource(R.drawable.ic_pizzahut);
holder.titlePromo.setText(itm.getTitlePromo());
holder.daysPromo.setText(itm.getDays());
holder.schedulePromo.setText(itm.getSchedule());

return rowView;
}
}

这里是 mi XML 文件:home_promo_item

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<RelativeLayout
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_alignBottom="@+id/box_info"
android:background="@color/promo_1"
android:id="@+id/box_promo">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-25%"
android:textColor="@color/white"
android:gravity="right"
android:textSize="20sp"
android:id="@+id/label_promo"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:paddingRight="5dp"
android:paddingBottom="5dp"
android:layout_marginLeft="25dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/box_promo"
android:id="@+id/box_info"
android:layout_toEndOf="@+id/box_promo"
android:background="@drawable/border_right">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@drawable/ic_pizzahut"
android:padding="10dp"
android:id="@+id/logo_promo"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/logo_promo"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_promo"
android:gravity="center"
android:text="EN TODAS NUESTRAS PIZZAS"
android:layout_marginTop="1dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/days_promo"
android:text="Promoción Valida de Lunes a Jueves"
android:layout_below="@+id/title_promo"
android:gravity="right"
android:layout_alignRight="@+id/title_promo" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/schedule_promo"
android:text="de 12:00 m a 5:00pm."
android:layout_below="@+id/days_promo"
android:layout_alignRight="@+id/days_promo" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>

最佳答案

在 lollipop 中,我们需要设置字符串的颜色,因为它会自动将其设置为白色,因此我无法看到对象中的所有字符串。

对不起我的英语,它不是我的母语

关于android - ListView Lollipop 不显示所有信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32149034/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com