You can try this :

public AlertDialog.Builder   setOnItemSelectedListener
(AdapterView.OnItemSelectedListener listener)


Get the item when its selected, and based on the button clicked you
can perform your action.


http://developer.android.com/reference/android/app/AlertDialog.Builder.html

- Moazzam
http://moazzam-khan.com/


On Feb 25, 11:03 am, Rafa <[email protected]> wrote:
> Hi every one. I have implemented a single choice dialog this way:
>
> On my strings.xml I defined the following array and strings:
>
> [syntax="xml"]
> <string name="titulo_pedir_tel">Ingresar número telefónico</string>
> <string name="accion_selecionar">Aceptar</string>
> <string name="accion_cancelar">Cancelar</string>
> <!-- Opciones del menu de envio -->
> <string-array name="select_dialog_items">
> <item>Enviar vía SMS</item>
> <item>Enviar vía email</item>
> </string-array>
> [/syntax]
>
> and my single choice dialog is defined as it follows in my main.class
>
> [syntax="java"]
> Builder builder = new AlertDialog.Builder(this);
> builder.setIcon(R.drawable.alert_dialog_icon);
> builder.setTitle(R.string.seleccionar_forma_envio);
> builder.setSingleChoiceItems(R.array.select_dialog_items, 0, new
> DialogInterface.OnClickListener()
> {
> public void onClick(DialogInterface dialog, int whichButton)
> {
> /* User clicked on a radio button do some stuff */}
> });
>
> builder.setPositiveButton(R.string.accion_selecionar, new
> DialogInterface.OnClickListener()
> {
> public void onClick(DialogInterface dialog, int whichButton)
> {
> /* User clicked Yes so do some stuff */}
> });
>
> builder.setNegativeButton(R.string.accion_cancelar, new
> DialogInterface.OnClickListener()
> {
> public void onClick(DialogInterface dialog, int whichButton)
> {
> /* User clicked No so do some stuff */}
> });
>
> builder.show();
> [/syntax]
>
> The idea of this is that the user of my app selects a item of the
> array an base of the selection to realize some action. My problem is
> that I don't know how to recognize which item of the array the user
> selected. How can I solve my problem? Thanks in advance.
>
> Regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to