java 检索从Adaptater RecyclerView修改到第一个活动的数组列表

js81xvg6  于 2022-12-17  发布在  Java
关注(0)|答案(1)|浏览(88)

我在一个活动中使用了RecyclerView。在Adaptater中我修改了一个ArrayList的内容。我如何在我的第一个活动中检索我修改过的ArrayList?非常感谢您的帮助。向Georges致以最诚挚的问候

holder.imageClick.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (laPlateaux.get(position).Cat.equals("U7")) {
                keyPlateau = "PlatU7" + "-" + zdte + "-" + laPlateaux.get(position).AccueilNum;}
            else {
                keyPlateau = "PlatU9" + "-" + zdte + "-" + laPlateaux.get(position).AccueilNum; }
            if (laPlateaux.get(position).Cat.equals("U7")) {
                 if (laPlateaux.get(position).Select.equals("N")){
                    mDatabase.child("PlateauxU7").child(keyPlateau).child("Selected").setValue("Y");
                    holder.imageClick.setImageDrawable(holder.itemView.getContext().getDrawable(R.drawable.valoknew));
                    laPlateaux.get(position).Select = "Y";
                     notifyDataSetChanged();}
                else {
                    mDatabase.child("PlateauxU7").child(keyPlateau).child("Selected").setValue("N");
                    holder.imageClick.setImageDrawable(holder.itemView.getContext().getDrawable(R.drawable.valnoknew));
                    laPlateaux.get(position).Select = "N";
                     notifyDataSetChanged();}}
            else {
                if (laPlateaux.get(position).Select.equals("N")){
                    mDatabase.child("PlateauxU9").child(keyPlateau).child("Selected").setValue("Y");
                    holder.imageClick.setImageDrawable(holder.itemView.getContext().getDrawable(R.drawable.valoknew));
                    laPlateaux.get(position).Select = "Y";
                    notifyDataSetChanged();}
                else {
                    mDatabase.child("PlateauxU9").child(keyPlateau).child("Selected").setValue("N");
                    holder.imageClick.setImageDrawable(holder.itemView.getContext().getDrawable(R.drawable.valnoknew));
                    laPlateaux.get(position).Select = "N";
                    notifyDataSetChanged();}}} }); }

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

uqcuzwp81#

我猜您必须在适配器中实现公共getter,仅此而已。
在适配器中

public List<PlaceholderItem> getKeyPlateau() {
    return keyPlateau;
}

在活动中

ArrayList<String> keyPlateau = adapter.getKeyPlateau();

相关问题