-1
When changing option it does not format the string values as shown in the image below.
Please, how could I fix this?
This is my code.
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.Toast;
public class RadioDialogFragment extends DialogFragment implements DialogInterface.OnClickListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle("Escolha um dos oito remédios naturais:")
.setSingleChoiceItems(R.array.remedios, 6, this)
.create();
}
@Override
public void onClick(DialogInterface dialog, int which) {
String[] remedios = getActivity().getResources().getStringArray(R.array.remedios);
String remedio = remedios[which];
Toast.makeText(getActivity(), "Você escolheu " + remedios, Toast.LENGTH_SHORT).show();
}
}
This is my Resource file where the list is.
<resources>
<string name="app_name">Diaglos</string>
<string name="txt_dialog">Abrir Dialog</string>
<string name="txt_dialog_simple">um simples dialog</string>
<string name="txt_dialog_radio">Dialog de Radio Button</string>
<string-array name="remedios">
<item>Ar puro</item>
<item>Água potável</item>
<item>Luz Solar</item>
<item>Alimentação Saudável</item>
<item>Prática de Atividade física</item>
<item>Domínio Próprio</item>
<item>Confiança em Deus</item>
</string-array>
</resources>
On the Oast there, you shouldn’t be passing only medicine instead of medicine?
– rodrigo.oliveira
That was the problem, thank you very much, it was really lack of attention.
– wladyband