Как установить значение editext в определенной строке в списке просмотра Android? - PullRequest
0 голосов
/ 30 октября 2019

У меня есть в списке, которые включают четыре элемента управления. мой взгляд как ниже. enter image description here


мой текстовый просмотр и флажки заполнены моим классом CamaResponse данные флажка и edittext должны быть сохранены в новом списке с именем Camas Я получаю значения для флажков правильно с их позициями, и я вставляю их с этой строкой кода в список Camas

mCamas.add(position, new Camas(mCamaResponse.get(position).getDescripcion(), "L",""));

 mCamas.add(position, new Camas(mCamaResponse.get(position).getDescripcion(), "O", ""));

Мне нужно сохранить значения edittextвведен в соответствии с их положением, спасибо за вашу помощь, затем я оставляю код моего адаптера.

public class CamaAdapter extends BaseAdapter {

private Context context;
private List<CamaResponse> mCamaResponse;
public static List<Camas> mCamas;


public CamaAdapter(Context context, List<CamaResponse> activitiesModelActividades) {

    this.context = context;
    this.mCamaResponse = activitiesModelActividades;
    this.mCamas =  new ArrayList<>() ;

}

@Override
public int getViewTypeCount() {
    if (getCount() > 0) {
        return getCount();
    } else {
        return super.getViewTypeCount();
    }
}

@Override
public int getItemViewType(int position) {

    return position;
}

@Override
public int getCount() {
    return mCamaResponse.size();
}

@Override
public Object getItem(int position) {
    return mCamaResponse.get(position);
}

@Override
public long getItemId(int position) {
    return 0;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final CamaAdapter.ViewHolder holder;

    if (convertView == null) {
        holder = new CamaAdapter.ViewHolder();
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.item_cama, null, true);


        convertView.setTag(holder);

        holder.question = (TextView) convertView.findViewById(R.id.texthabitacion);
        holder.nota = (ImageView) convertView.findViewById(R.id.imgNota);
        holder.yes = (RadioButton) convertView.findViewById(R.id.yes);
        holder.no = (RadioButton) convertView.findViewById(R.id.no);
        holder.verNota = (LinearLayout) convertView.findViewById(R.id.lbNota);
        holder.IngresarData = (EditText) convertView.findViewById(R.id.edtObhservaciones);




        if(mCamaResponse.get(position).getEstadoNoche().equals("L") || mCamaResponse.get(position).getEstadoNoche().equals("R"))
        {
            holder.yes.setChecked(true);


            mCamas.add(position, new Camas(mCamaResponse.get(position).getDescripcion(), "L",""));


        }
        else if (mCamaResponse.get(position).getEstadoNoche().equals("C")){

            holder.no.setChecked(true);

            mCamas.add(position, new Camas(mCamaResponse.get(position).getDescripcion(), "O", ""));


        }

        holder.IngresarData.setText(mCamas.get(position).getDescripcion());
        holder.nota.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                holder.verNota.setVisibility(View.VISIBLE);

            }
        });





    } else {
        holder = (CamaAdapter.ViewHolder) convertView.getTag();
    }





    holder.yes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked)


                mCamas.add(position, new Camas(mCamaResponse.get(position).getDescripcion(), "L", ""));

        }
    });
    // perform setOnCheckedChangeListener event on no button
    holder.no.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // set No values in ArrayList if RadioButton is checked
            if (isChecked)

                mCamas.set(position, new Camas(mCamaResponse.get(position).getDescripcion(), "O", ""));

        }
    });





    return convertView;
}

private class ViewHolder {

    protected TextView  question;
    ImageView  nota;
    RadioButton yes,no;
    LinearLayout verNota;
    EditText IngresarData;
}  
  }

для получения данных.

public class CamaResponse {
@SerializedName("codigo")
@Expose
public String codigo;
@SerializedName("descripcion")
@Expose
public String descripcion;
@SerializedName("estadoDia")
@Expose
public String estadoDia;
@SerializedName("estadoNoche")
@Expose
public String estadoNoche;

public String getCodigo() {
    return codigo;
}

public void setCodigo(String codigo) {
    this.codigo = codigo;
}

public String getDescripcion() {
    return descripcion;
}

public void setDescripcion(String descripcion) {
    this.descripcion = descripcion;
}

public String getEstadoDia() {
    return estadoDia;
}

public void setEstadoDia(String estadoDia) {
    this.estadoDia = estadoDia;
}

public String getEstadoNoche() {
    return estadoNoche;
}

public void setEstadoNoche(String estadoNoche) {
    this.estadoNoche = estadoNoche;
}

public CamaResponse(String codigo, String descripcion, String estadoDia, String estadoNoche) {
    this.codigo = codigo;
    this.descripcion = descripcion;
    this.estadoDia = estadoDia;
    this.estadoNoche = estadoNoche;
}

}

для сохраненияэто в моем временном списке

public class Camas implements Serializable {
private String codigoCama;
private String estado;
private String descripcion;



public Camas(String codigoCama, String estado, String descripcion) {
    this.codigoCama = codigoCama;
    this.estado = estado;
    this.descripcion = descripcion;

}



public String getCodigoCama() {
    return codigoCama;
}

public void setCodigoCama(String codigoCama) {
    this.codigoCama = codigoCama;
}

public String getEstado() {
    return estado;
}

public void setEstado(String estado) {
    this.estado = estado;
}

public String getDescripcion() {
    return descripcion;
}

public void setDescripcion(String descripcion) {
    this.descripcion = descripcion;
}

}

...