Pass gridView values to edit Activity

Asked

Viewed 42 times

0

Please, whoever can help me I’m very grateful

I’m having trouble passing the value of radioGroupOps for editing screen.

 // Abre a tela de cadastro/edição com os registros para edição.
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
      textView = (TextView) view.findViewById(R.id.txtId);
      String text = textView.getText().toString();
      Intent AbreTCadastro = new Intent(getApplicationContext(), TCadastro.class);
      AbreTCadastro.putExtra("notas", Integer.parseInt(text));
      startActivity(AbreTCadastro);
            finish();
        }
    });
    Activity de cadastro/edição que recebe os dados.

    editTextHoras = (EditText) this.findViewById(R.id.IdHoras);
    editTextDestino = (EditText) findViewById(R.id.IdAutoCompletDestino);
    editTextDia = (EditText) findViewById(R.id.IdAutoCompletDia);
    editTextLinha = (EditText) findViewById(R.id.IdAutoCompletLinha);

    radioGroupOpcoes = (RadioGroup) this.findViewById(R.id.IdCumpriuHora);
    radioCumpriuHoraSim = (RadioButton) this.findViewById(R.id.IdRadioSim);
    radioCumpriuHoraNao = (RadioButton) this.findViewById(R.id.IdRadioNao);
    radioConfirmar = (RadioButton) this.findViewById(R.id.IdRadioConfirmar);

    Intent intent = getIntent();
    tcadastro = intent.getIntExtra("notas", 0);
    MdConsulta salva = new MdConsulta(this);
    MdCampos notas = new MdCampos();
    notas = salva.getNotasById(tcadastro);
    editTextHoras.setText(notas.horas);
    editTextDestino.setText(notas.destino);
    editTextDia.setText(notas.dia);
    editTextLinha.setText(notas.linha);
    if (radioCumpriuHoraSim.isChecked()) radioCumpriuHoraSim.setChecked(true);
    if (radioCumpriuHoraNao.isChecked()) radioCumpriuHoraNao.setChecked(true);
    if (radioConfirmar.isChecked()) radioConfirmar.setChecked(true);

Só os editTextHoras, editTextDestino, editTextDia e editTextLinha retornam para a edição, Os RadioButtons não retorna.

Follow the other part of the code

public class InsereDados extends CursorAdapter {

    private LayoutInflater mInflater;
    public InsereDados(Context context, Cursor c, int flags) {
        super(context, c, flags);
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    static class ViewHolder {
        TextView TxtId;
        TextView TxtDestino;
        TextView TxtDia;
        TextView TxtHora;
        TextView TxtLinha;
        TextView TxtCumpriuhora;
        TextView TxtCheio_vazio;
        TextView textView;
    }

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

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

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        View   viewLista    =    mInflater.inflate(R.layout.inseredados, parent, false);
        ViewHolder holder  =   new ViewHolder();
        holder.TxtId    =   (TextView)  viewLista.findViewById(R.id.txtId);
        holder.TxtDestino    =   (TextView)  viewLista.findViewById(R.id.txtDestino);
        holder.TxtDia   =   (TextView)  viewLista.findViewById(R.id.txtDia);
        holder.TxtHora   =   (TextView)  viewLista.findViewById(R.id.txtHora);
        holder.TxtLinha   =   (TextView)  viewLista.findViewById(R.id.txtLinha);
        holder.TxtCumpriuhora   =   (TextView)  viewLista.findViewById(R.id.txtCumpriuhora);
        holder.TxtCheio_vazio   =   (TextView)  viewLista.findViewById(R.id.txtSituacao);
        viewLista.setTag(holder);
        return viewLista;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
ViewHolder holder = (ViewHolder) view.getTag();
holder.TxtId.setText(cursor.getString(cursor.getColumnIndex(MdCampos.KEY_ID))); holder.TxtDestino.setText(cursor.getString(cursor.getColumnIndex(BDdestino.KEY_DESTINO))); holder.TxtDia.setText(cursor.getString(cursor.getColumnIndex(MdCampos.KEY_dia))); holder.TxtHora.setText(cursor.getString(cursor.getColumnIndex(MdCampos.KEY_horas))); holder.TxtLinha.setText(cursor.getString(cursor.getColumnIndex(BDlinhas.KEY_LINHA)));
holder.TxtCumpriuhora.setText(cursor.getString(cursor.getColumnIndex(MdCampos.KEY_cumpriuhora)));  holder.TxtCheio_vazio.setText(cursor.getString(cursor.getColumnIndex(MdCampos.KEY_cheio_vazio)));    
    }
}
  • Where you save the boolean values of radiogroup?

  • Thank you Rodrigo and sorry for the delay in returning your question.

  • I reversed the editing because I didn’t realize how it improved in any aspect the content of it, apart from the fact that the title was changed to something unrelated to the question. If the reversed edition was important, I apologize and ask you to redo it in the correct way, without harming the title and formatting the code correctly. See how correctly use the editor.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.