// Заполняем нашими вьюшками и подставляем значения из РейЛиста с данными
for ( i =0; i<counter;i++) {
ImageView picture = new ImageView(this); // Фотография автозапчасти
EditText changeOfQuantity = new EditText(this); // Едит Текст с изменением количества автозапчастей в заказе
ImageView editeOfQuantity = new ImageView(this); // Кнопка редактировать количество автозапчастей
deleteOfPart = new ImageView(this); // Кнопка удалить автозапчасть из корзины
TextView Number = new TextView(this); // Номер автозапчасти
TextView Description = new TextView(this); //Создаем Вьюшку текста Описание автозапчасти
TextView Price = new TextView(this); //Создаем Вьюшку текста цены автозапчасти
TextView Brand = new TextView(this); //Создаем Вьюшку текста бренда автозапчасти
TextView deliveryOfTime = new TextView(this); //Срок доставки
mainFrame = new FrameLayout(this); //Параметры ФреймЛайаута
LinearLayout.LayoutParams frameLayoutFirstCartParams = new LinearLayout.LayoutParams(tenPixelsWight*80,tenPixelsHeight*50);
frameLayoutFirstCartParams.setMargins(0, tenPixelsHeight * 4, 0, 0); //ФреймЛайаут
mainFrame.setTag(i);
mainFrame.setLayoutParams(frameLayoutFirstCartParams);
mainLinearLayout.addView(mainFrame);
FrameLayout.LayoutParams frameLayoutPictureParams = new FrameLayout.LayoutParams(tenPixelsWight*15, tenPixelsHeight*15);
frameLayoutPictureParams.setMargins(tenPixelsWight/2, tenPixelsHeight, 0, 0);
picture.setLayoutParams(frameLayoutPictureParams); // Фотография автозапчастей
picture.setBackgroundResource(R.drawable.camera);
mainFrame.addView(picture);
FrameLayout.LayoutParams numberOfPartParams = new FrameLayout.LayoutParams(tenPixelsWight*45, tenPixelsHeight*5);
numberOfPartParams.setMargins(tenPixelsWight * 20, tenPixelsHeight * 11, 0, 0);
Number.setLayoutParams(numberOfPartParams); // Артикул автозапчасти
Number.setText("Номер запчасти: " + article.get(i));
mainFrame.addView(Number);
FrameLayout.LayoutParams frameLayoutDeliveryTextParams = new FrameLayout.LayoutParams(tenPixelsWight * 45, tenPixelsHeight*5);
frameLayoutDeliveryTextParams.setMargins(tenPixelsWight * 20, tenPixelsHeight * 6, 0, 0);
deliveryOfTime.setTextSize(15); // Cрок доставки автозапчасти
deliveryOfTime.setText("Cрок доставки: " + delivery.get(i) + " дней");
deliveryOfTime.setLayoutParams(frameLayoutDeliveryTextParams);
mainFrame.addView(deliveryOfTime);
FrameLayout.LayoutParams frameLayoutPriceTextParams = new FrameLayout.LayoutParams(tenPixelsWight * 25, tenPixelsHeight*5);
frameLayoutPriceTextParams.setMargins(tenPixelsWight * 60, tenPixelsHeight * 10, 0, 0);
Price.setTextColor(Color.parseColor("#D50000")); // Цена автозапчасти
Price.setTextSize(20);
Price.setText(price.get(i));
Price.setLayoutParams(frameLayoutPriceTextParams);
mainFrame.addView(Price);
FrameLayout.LayoutParams frameLayoutBrandTextParams = new FrameLayout.LayoutParams(tenPixelsWight*20, tenPixelsHeight*5);
frameLayoutBrandTextParams.setMargins(tenPixelsWight * 20, tenPixelsHeight * 15, 0, 0);
Brand.setTextColor(Color.parseColor("#D50000")); // Бренд автозапчасти
Brand.setTextSize(20);
Brand.setText(brand.get(i));
Brand.setLayoutParams(frameLayoutBrandTextParams);
mainFrame.addView(Brand);
FrameLayout.LayoutParams frameLayoutEditQuantityParams = new FrameLayout.LayoutParams(tenPixelsWight*50,tenPixelsHeight*10);
frameLayoutEditQuantityParams.setMargins(tenPixelsWight/2, tenPixelsHeight * 20, 0, 0);
changeOfQuantity.setHint("Изменить количество"); // Изменение количества автозапчастей в детали
changeOfQuantity.setLayoutParams(frameLayoutEditQuantityParams);
mainFrame.addView(changeOfQuantity);
FrameLayout.LayoutParams frameLayoutDescriptionParams = new FrameLayout.LayoutParams(tenPixelsWight*50,tenPixelsHeight*5);
frameLayoutDescriptionParams.setMargins(tenPixelsWight * 20, tenPixelsHeight/4, 0, 0);
Description.setText(description.get(i));
Description.setTextSize(20); // Описание автозапчасти
Description.setTextColor(Color.parseColor("#000000"));
Description.setLayoutParams(frameLayoutDescriptionParams);
mainFrame.addView(Description);
FrameLayout.LayoutParams EditQuantityParams = new FrameLayout.LayoutParams(tenPixelsWight*7,tenPixelsHeight*7);
EditQuantityParams.setMargins(tenPixelsWight * 52, tenPixelsHeight * 20, 0, 0);
editeOfQuantity.setClickable(true);
editeOfQuantity.setBackgroundResource(R.drawable.undo); //Кнопка исправить количество
editeOfQuantity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
editeOfQuantity.setLayoutParams(EditQuantityParams);
mainFrame.addView(editeOfQuantity);
FrameLayout.LayoutParams deletePartsParams = new FrameLayout.LayoutParams(tenPixelsWight*7,tenPixelsHeight*7);
deletePartsParams.setMargins(tenPixelsWight * 60, tenPixelsHeight * 20, 0, 0);
deleteOfPart.setBackgroundResource(R.drawable.delete); //Кнопка удалить автозапчасть
deleteOfPart.setClickable(true);
deleteOfPart.setTag(i);
deleteOfPart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mainFrame.removeView(deleteOfPart);
}
});
deleteOfPart.setLayoutParams(deletePartsParams);
mainFrame.addView(deleteOfPart);
}
它工作!谢谢你非常匹配的帮助! – Slavik