Есть такой Layout(Изображение) который мы получаем в RecyclerView, таких layout-ов можно создать несколько. Как я могу получить значение из каждого?
Вот код моего Адаптера:
private Context mContext;
private int flag;
public PackagesAdapter(Context context, int flag){
this.mContext = context;
this.flag = flag;
}
@NonNull
@Override
public PackagesAdapter.PackagesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.packages_layout, parent, false);
PackagesAdapter.PackagesViewHolder packagesViewHolder = new PackagesAdapter.PackagesViewHolder(view);
return packagesViewHolder;
}
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onBindViewHolder(@NonNull PackagesAdapter.PackagesViewHolder holder, int position) {
holder.id.setText(String.valueOf(position + 1));
String packName = holder.name.getText().toString();
String components = holder.components.getText().toString();
double price;
if (holder.price.getText().toString().equals(""))
price = 0.00;
else
price = Double.parseDouble(holder.price.getText().toString());
CreateEvent2 event = new CreateEvent2(packName, Global.packageDates, price, components);
Global.moreEvents.add(event);
// В классе Global имеется List<String> moreEvents = new Arraylist<>();
}
@Override
public int getItemCount() {
return flag;
}
public class PackagesViewHolder extends RecyclerView.ViewHolder {
private LinearLayout bankAccount;
private TextView id, currency, info;
private EditText datePicker1, price, components, name;
public PackagesViewHolder(@NonNull View itemView) {
super(itemView);
id = itemView.findViewById(R.id.packageId);
name = itemView.findViewById(R.id.packageMoreName);
datePicker1 = itemView.findViewById(R.id.packageMoreDates);
bankAccount = itemView.findViewById(R.id.packageBankAccount);
currency = itemView.findViewById(R.id.packageMoreCurrency);
info = itemView.findViewById(R.id.packageTransactionInfo);
price = itemView.findViewById(R.id.packageMorePrice);
components = itemView.findViewById(R.id.packageMoreComponents);
}
}