Capture the radio button and save Text to the database

Asked

Viewed 254 times

1

Guys I’m managing to capture the selected Radiobuton to save in the bank, I need to capture the radio button in 3 ways, these 2 radiobutons are in a Radiogrup, the radiobutton is the type.

 private Adicionar setAdicionar(Cursor cursor) {
        Adicionar adicionar = new Adicionar();
        adicionar.setId(cursor.getInt(cursor.getColumnIndex("_id")));
        adicionar.setValor(cursor.getString(cursor.getColumnIndex("valor")));
        adicionar.setTipo(cursor.getString(cursor.getColumnIndex("tipo")));
        adicionar.setCategoria(cursor.getString(cursor.getColumnIndex("categoria")));
        adicionar.setData(cursor.getString(cursor.getColumnIndex("data")));
        adicionar.setDescricao(cursor.getString(cursor.getColumnIndex("descricao")));
        return adicionar;
    }
}

And here I need to pick up the selected

private Adicionar lerDadosDoForm(Adicionar adicionar) {
        adicionar.setValor(txtValor.getText().toString());
        adicionar.setCategoria(edtCategoria.getText().toString());
        adicionar.setData(edtData.getText().toString());
        adicionar.setDescricao(edtDescricao.getText().toString());
        adicionar.setTipo(rdbGasto.getText().toString());


        return adicionar;
    }

1 answer

0

To get the selected radiobutton text I use the following code:

RadioButton selecionado;
String situacao;
int idSelecionado = status.getCheckedRadioButtonId(); //pega o id do RadioButton selecionado
selecionado = findViewById(idSelecionado); //Seleciona o RB selecionado pelo id
situacao = String.valueOf(selecionado.getText()); //Pega o texto do RB
  • what would be the Selected and what would be the status?

  • Sorry, information added in the reply.

Browser other questions tagged

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