如何将所有值添加到 recyclerview 并将其发送到离子库

how to get all values added to recyclerview and send it to ion lib

所以我试图添加 recyclerview 数据列表并将其发送到离子库,当我使用下面的方法时我只得到一个元素,因为我必须将 for() 中的字符串更改为 String fav =null outide of for()而 log.d 只显示最后的结果。我需要得到所有,这样我就可以发送到 senddata() 到 ion lib

FavModelClass

私人字符串收藏夹; 私有字符串 user_id;

public FavModelClass(String fav, String user_id) {
    this.fav = fav;
    this.user_id = user_id;
}

public String getFav() {
    return fav;
}

public void setFav(String fav) {
    this.fav = fav;
}

public String getUser_id() {
    return user_id;
}

public void setUser_id(String user_id) {
    this.user_id = user_id;
}
}

适配器

 public class FavAdapter extends 
 RecyclerView.Adapter<FavAdapter .MyViewHolder> {

private List<FavModelClass> favModelClassList;
private Context beddingContext;

public FavAdapter (List<FavModelClass> favModelClassList, Context 
beddingContext) {
    this.favModelClassList= favModelClassList;
    this.beddingContext = beddingContext;
}

@NonNull
@Override
public FavAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup 
    parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.amenitylayout,parent,false);
    FavAdapter .MyViewHolder holder = new FavAdapter .MyViewHolder(view);
    return holder;
}



@Override
public void onBindViewHolder(@NonNull FavAdapter.MyViewHolder holder, int i) {
    final FavModelClassdata = favModelClassList.get(i);
    holder.ac_bedding_type.setText(data.getFav()+" "+"MAX:"+data.getUser_id());

    holder.delete_entry.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            removeAt(holder.getAdapterPosition());
        }
    });


}

public void removeAt(int position) {
    favModelClassList.remove(position);
    notifyItemRemoved(position);
    notifyItemRangeChanged(position, favModelClassList.size());
}

@Override
public int getItemCount() {
    return favModelClassList.size();
}

public class MyViewHolder extends RecyclerView.ViewHolder {

    private TextView ac_bedding_type;
    private ImageButton delete_entry;
    public MyViewHolder(@NonNull View v) {
        super(v);

        ac_bedding_type = v.findViewById(R.id.ac_amenity_name);
        delete_entry = v.findViewById(R.id.delete_amenity_entry);
    }
}
}

主要activity

 fav_recycler = findViewById(R.id.fave_recycler);
    GridLayoutManager layoutManager1 = new GridLayoutManager(getApplicationContext(), 2,GridLayoutManager.VERTICAL, false);
    fav_recycler.setHasFixedSize(true);
    fav_recycler.setLayoutManager(layoutManager1);
    favModelClassList= new ArrayList<>();

    addfavamenity.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            favModelClassList.add(new FavModelClass(
                    amenityET.getText().toString(),
                    user_idET.getText().toString()
            ));

            amenityET.setText("");
            user_idET.setText("");
            FavAdapter adapter = new FavAdapter (favModelClassList, getApplicationContext());
            adapter.notifyDataSetChanged();
            fav_recycler.setAdapter(adapter);


            for (int i = 0; i < favModelClassList.size(); i++) {
                final FavModelClassList data = favModelClassList.get(i);
                final String fav= data.getFav();
                final String user_id = data.getUser_id();

              Log.d(TAG, "onClick: "+ fav);

            }



        }
    });
ArrayList d = new ArrayList();

for (int i = 0; i < favModelClassList.size(); i++) {
    final FavModelClassList data = favModelClassList.get(i);
    
    d.add(data.getFav());
}

Log.d(TAG, "onClick: " + d);