I managed to solve this wayin the method save private fun save()
{ val nome = edit_nome_Pessoa.text.toString()
val idade = ("" + (seekbarIdade.progress + 10) + " anos")
val sexo_Id = findViewById<RadioGroup>(R.id.radioGroup_sexo_Pessoa)
val sexo = (if (sexo_Id.checkedRadioButtonId == R.id.radio_feminino_Pessoa) "Feminino" else "Masculino").toString()
val dt_nasc = edit_calendar_Pessoa.text.toString().substring(24..33)
val rg = edit_rg_Pessoa.text.toString()
val cpf = edit_cpf_Pessoa.text.toString()
val rua = edit_rua_Pessoa.text.toString()
val num_casa = editNumeroCasa_Pessoa.text.toString()
val bairro = edit_bairro_Pessoa.text.toString()
val complemento = edit_comeplemento_Pessoa.text.toString()
val cep = edit_cep_Pessoa.text.toString()
val cidade = edit_cidade_Pessoa.text.toString()
val estado = edit_uf_Pessoa.text.toString()
val telefone = edit_telefone_Pessoa.text.toString()
val local_estudo = edit_escola_Pessoa.text.toString()
val nome_mae = edit_mae_Pessoa.text.toString()
val nome_pai = edit_pai_Pessoa.text.toString()
val resposavel = edit_resp_Pessoa.text.toString()
val rg_resp = edit_rg_resp_Pessoa.text.toString()
val cpf_resp = edit_cpf_resp_Pessoa.text.toString()
val telefone_resp = edit_tel_resp_Pessoa.text.toString()
mRegraNegocio_Pessoa.inserir_Pessoa_Businnes(
nome, idade, sexo, dt_nasc, rg, cpf
, rua, num_casa, bairro, complemento, cep, cidade, estado
, telefone, local_estudo, nome_mae, nome_pai
, resposavel, rg_resp, cpf_resp, telefone_resp)
Toast.makeText(this, "preencher os campos", Toast.LENGTH_LONG).show()
finish()
}
in validation functionfun valida() : Boolean
{
val name = findViewById(R.id.edit_name_Person)
if (name.text.length == 0) { name.setError() Please fill in required field") } /* val idade = findViewById<SeekBar>(R.id.seekBar_Idade_Pessoa)
if (idade.text.length == 0) idade.setError("Por favor preenche campo obrigatório")*/
val sexo = findViewById<RadioGroup>(R.id.radioGroup_sexo_Pessoa)
if (nome.text.length == 0) nome.setError("Por favor preenche campo obrigatório")
val dt_nasc = findViewById<TextView>(R.id.edit_calendar_Pessoa)
if (dt_nasc.text.length == 0) dt_nasc.setError("Por favor preenche campo obrigatório")
val rg = findViewById<EditText>(R.id.edit_rg_Pessoa)
if (rg.text.length == 0) rg.setError("Por favor preenche campo obrigatório")
val cpf = findViewById<EditText>(R.id.edit_cpf_Pessoa)
if (cpf.text.length == 0) cpf.setError("Por favor preenche campo obrigatório")
val rua = findViewById<EditText>(R.id.edit_rua_Pessoa)
if (rua.text.length == 0) rua.setError("Por favor preenche campo obrigatório")
val num_casa = findViewById<EditText>(R.id.editNumeroCasa_Pessoa)
if (num_casa.text.length == 0) num_casa.setError("Por favor preenche campo obrigatório")
val bairro = findViewById<EditText>(R.id.edit_bairro_Pessoa)
if (bairro.text.length == 0) bairro.setError("Por favor preenche campo obrigatório")
val complemento = findViewById<EditText>(R.id.edit_comeplemento_Pessoa)
if (complemento.text.length == 0) complemento.setError("Por favor preenche campo obrigatório")
val cep = findViewById<EditText>(R.id.edit_cep_Pessoa)
if (cep.text.length == 0) cep.setError("Por favor preenche campo obrigatório")
val cidade = findViewById<EditText>(R.id.edit_cidade_Pessoa)
if (cidade.text.length == 0) cidade.setError("Por favor preenche campo obrigatório")
val estado = findViewById<EditText>(R.id.edit_uf_Pessoa)
if (rg.text.length == 0) rg.setError("Por favor preenche campo obrigatório")
val telefone = findViewById<EditText>(R.id.edit_telefone_Pessoa)
if (telefone.text.length == 0) telefone.setError("Por favor preenche campo obrigatório")
val local_estudo = findViewById<EditText>(R.id.edit_escola_Pessoa)
if (local_estudo.text.length == 0) local_estudo.setError("Por favor preenche campo obrigatório")
val nome_mae = findViewById<EditText>(R.id.edit_mae_Pessoa)
if (nome_mae.text.length == 0) nome_mae.setError("Por favor preenche campo obrigatório")
val nome_pai = findViewById<EditText>(R.id.edit_pai_Pessoa)
if (nome_pai.text.length == 0) nome_pai.setError("Por favor preenche campo obrigatório")
val resposavel = findViewById<EditText>(R.id.edit_resp_Pessoa)
if (resposavel.text.length == 0) resposavel.setError("Por favor preenche campo obrigatório")
val rg_resp = findViewById<EditText>(R.id.edit_rg_resp_Pessoa)
if (rg_resp.text.length == 0) rg_resp.setError("Por favor preenche campo obrigatório")
val cpf_resp = findViewById<EditText>(R.id.edit_cpf_resp_Pessoa)
if (cpf_resp.text.length == 0) cpf_resp.setError("Por favor preenche campo obrigatório")
val telefone_resp = findViewById<EditText>(R.id.edit_tel_resp_Pessoa)
if (telefone_resp.text.length == 0) telefone_resp.setError("Por favor preenche campo obrigatório")
return nome.length() > 0
/*&& idade.length > 0
&& sexo.length > 0*/
&& dt_nasc.length() > 0
&& rg.length() > 0
&& cpf.length() > 0
&& rua.length() > 0
&& num_casa.length() > 0
&& bairro.length() > 0
&& complemento.length() > 0
&& cep.length() > 0
&& cidade.length() > 0
&& estado.length() > 0
&& telefone.length() > 0
&& local_estudo.length() > 0
&& nome_mae.length() > 0
&& nome_pai.length() > 0
&& resposavel.length() > 0
&& rg_resp.length() > 0
&& cpf_resp.length() > 0
&& telefone_resp.length() > 0
}
in the onclice method where I call the click save check firstif (id == R.id.btn_salvar)
{
if (valida()
{
save()
) }