라디오 버튼의 텍스트를 가져와야합니다. 코드에는 4 개의 방사선 그룹과 13 개의 라디오 버튼이 있습니다. 누군가가 버튼을 선택하면 그 텍스트를 변수에 전송 한 다음 투표자에게 전자 메일을 보냅니다.Xamarin Android의 라디오 버튼에서 값을 얻는 방법은 무엇입니까?
using Android.App;
using Android.Widget;
using Android.OS;
using System.Collections;
using System;
namespace WhrReconigzer
{
[Activity(Label = "WhrReconigzer", MainLauncher = true)]
public class MainActivity : Activity
{
private ArrayList enderecos;
TextView queroreconhecer;
TextView crie;
TextView conquiste;
TextView entregue;
TextView viva;
TextView comentar;
EditText comentário;
Spinner spinner;
ArrayAdapter adapter;
RadioButton rdbTerPaixao;
RadioButton rdbSerOusado;
RadioButton rdbJogueParaGanhar;
RadioButton rdbLiberarOsTalentos;
RadioButton rdbUmaWhirlpool;
RadioButton rdbLiderarComVelocidade;
RadioButton rdbSeroDono;
RadioButton rdbSerFranco;
RadioButton rdbRespeito;
RadioButton rdbIntegridade;
RadioButton rdbDiversidadeeInclusao;
RadioButton rdbTrabalhoDeEquipe;
RadioButton rdbEspiritoDeVitoria;
RadioGroup rdgcrie;
RadioGroup rdgconquiste;
RadioGroup rdgentregue;
RadioGroup rdgviva;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
//preenche o arraylist com os dados
GetEmails();
//cria a instância do spinner declarado no arquivo Main
spinner = FindViewById<Spinner>(Resource.Id.spnDados);
//cria textview
queroreconhecer = FindViewById<TextView>(Resource.Id.txtReconhecer);
crie = FindViewById<TextView>(Resource.Id.txtCrie);
conquiste = FindViewById<TextView>(Resource.Id.txtConquiste);
entregue = FindViewById<TextView>(Resource.Id.txtEntregue);
viva = FindViewById<TextView>(Resource.Id.txtViva);
comentar = FindViewById<TextView>(Resource.Id.txtComentário);
comentário = FindViewById<EditText>(Resource.Id.edtComentario);
rdbTerPaixao = FindViewById<RadioButton>(rdgcrie.CheckedRadioButtonId);
rdbSerOusado = FindViewById<RadioButton>(rdgcrie.CheckedRadioButtonId);
rdbJogueParaGanhar = FindViewById<RadioButton>(rdgcrie.CheckedRadioButtonId);
rdbLiberarOsTalentos = FindViewById<RadioButton>(rdgconquiste.CheckedRadioButtonId);
rdbUmaWhirlpool = FindViewById<RadioButton>(rdgconquiste.CheckedRadioButtonId);
rdbLiderarComVelocidade = FindViewById<RadioButton>(rdgentregue.CheckedRadioButtonId);
rdbSeroDono = FindViewById<RadioButton>(rdgentregue.CheckedRadioButtonId);
rdbSerFranco = FindViewById<RadioButton>(rdgentregue.CheckedRadioButtonId);
rdbRespeito = FindViewById<RadioButton>(rdgviva.CheckedRadioButtonId);
rdbIntegridade = FindViewById<RadioButton>(rdgviva.CheckedRadioButtonId);
rdbDiversidadeeInclusao = FindViewById<RadioButton>(rdgviva.CheckedRadioButtonId);
rdbTrabalhoDeEquipe = FindViewById<RadioButton>(rdgviva.CheckedRadioButtonId);
rdbEspiritoDeVitoria = FindViewById<RadioButton>(rdgviva.CheckedRadioButtonId);
rdgcrie = FindViewById<RadioGroup>(Resource.Id.rdgCrie);
rdgconquiste = FindViewById<RadioGroup>(Resource.Id.rdgConquiste);
rdgentregue = FindViewById<RadioGroup>(Resource.Id.rdgEntregue);
rdgviva = FindViewById<RadioGroup>(Resource.Id.rdgViva);
// cria o adapter usando o leiaute SimpleListItem e o arraylist
adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, enderecos);
//vincula o adaptador ao controle spinner
spinner.Adapter = adapter;
//define o evento ItemSelected para exibir o item selecionado
spinner.ItemSelected += Spinner_ItemSelected;
if (rdbDiversidadeeInclusao.getCheckedRadioButtonId() != -1)
{
int id = rg1.getCheckedRadioButtonId();
View radioButton = rg1.findViewById(id);
int radioId = radioGroup.indexOfChild(radioButton);
RadioButton btn = (RadioButton)rg1.getChildAt(radioId);
String selection = (String)btn.getText();
}
}
//colocar o nome ao invés do email
private void GetEmails()
{
enderecos = new ArrayList();
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("ana_carolina_simoes @whirlpool.com");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]hirlpool.com");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("ricardo_matos_campaneruti @whirlpool.com");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
enderecos.Add("[email protected]");
}// fim getEmails
private void Spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
Spinner spinner = (Spinner)sender;
string toast = string.Format("Colaborador selecionado: {0}", spinner.GetItemAtPosition(e.Position));
Toast.MakeText(this, toast, ToastLength.Long).Show();
}
}
}
나는 rdbIntegridade.getCheckedRadioButtonId()를 사용한다 ?
그리고 radiobuttons 값 + EditText 필드에있을 주석을 전달하는 전자 메일을 보내는 단추를 만드는 방법을 알고 싶습니다.
정말 그 이메일이 존재하지 않기를 바란다. #JSaySaying – rmjoia