2

У меня есть представление списка, которое отлично работает в какой-либо версии Android, но в леденце в списке просмотра не отображается вся информация (всего одна строка из 5). В моем приложении у меня есть только деятельность, которая простирается от AppCompatActivity, вот мой адаптерListView Lollipop не отображает всю информацию

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; 
    } 
} 

Здесь ми 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>

+0

Опубликовать home_promo_item. –

+0

Post ListView элемент XML-макет. Ваш ViewHolder не нужен –

+0

home_promo_item готов к публикации! @dieter_h –

ответ

1

В lollipop нам нужно установить цвет строк, потому что он положил его белым автоматически, по этой причине я не мог видеть все строки из моего объекта.

Извините за мой английский, это не мой родной язык

0

Сообщение home_promo_item, вероятно, ваш LinearLayout горизонтален , в то время как VERTICAL должен отображать строки внутри ListView.

+0

является вертикальным :(, и это происходит только с lollipop –

+0

ну, не знаю, тогда, извините, нужно посмотреть конкретно для леденца –

Смежные вопросы