I have a recyclerview in my android project and in the recyclerview im populating the name of the any items and it have EditText corresponding to every name view inside recyclerview, which means the person can edit the price of each item inside recyclerview. Now outside recyclerview i have a button which when clicked a POST request is called and the names and their corresponding prices are updated. I can't find a way by which i get all the data from recyclerview back to my fragment.
My sample code to understand the problem
public class TestsListAdapterLabsInside extends RecyclerView.Adapter<TestsListAdapterLabs.MyHolder> {
Context context;
ArrayList<TestListLabRetro> arrayList;
double[] TOTAL;
public TestsListAdapterLabsInside(Context context, ArrayList<TestListLabRetro> arrayList) {
this.context = context;
this.arrayList = arrayList;
this.TOTAL = new double[arrayList.size()];
}
@NonNull
@Override
public TestsListAdapterLabs.MyHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.recyclerview_test_labs2, viewGroup, false);
return new TestsListAdapterLabs.MyHolder(v);
}
@Override
public void onBindViewHolder(@NonNull app.dezignoo.knockadoc.Adapters.TestsListAdapterLabs.MyHolder myHolder, final int i) {
myHolder.name.setText(arrayList.get(i).getName());
myHolder.slno.setText(String.valueOf(i + 1));
myHolder.price.setText(arrayList.get(i).getPrice());
}
@Override
public int getItemCount() {
return arrayList.size();
}
public class MyHolder extends RecyclerView.ViewHolder {
TextView slno, name;
TextView price;
public MyHolder(View itemView) {
super(itemView);
name = itemView.findViewById(R.id.testName);
slno = itemView.findViewById(R.id.slno);
price = itemView.findViewById(R.id.testPrice);
}
}
}
this Adapter is defined below my fragment. I want a final list of all the <name, price> from the recyclerview in my fragment to update to the server.
Thankyou in advance.