Hi all,

Thanks to help people!

I use an AlertDialog with list (singlechoice->radioButtons). When I
choose an item from the list, a toast come and I do a setText of the
item on a textView.
Everything works when I declare my items like this:
--------------------------------------------------------------------------------------------------------------------------------------------------
 
((ImageButton)findViewById(R.id.pickPays)).setOnClickListener(new
OnClickListener(){

            public void onClick(View v) {

                final CharSequence[] items = {"United States",
"France", "Sweden"};
                AlertDialog.Builder builder = new
AlertDialog.Builder(Postit.this);
                builder.setTitle("Selectionne ton pays");
                builder.setSingleChoiceItems(items, -1, new
DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int
item) {
                        dialog.cancel();
                        Toast.makeText(getApplicationContext(),
items[item] , Toast.LENGTH_LONG).show();
                        ((TextView)
findViewById(R.id.paysDisplay)).setText(items[item]);
                    }
                });
                AlertDialog alert = builder.create();
                alert.show();

            }
        });

--------------------------------------------------------------------------------------------------------


But I want declare my items in a array.xml
So I created an array.xml 'pays.xml' and I changed my code like this.
The problem is: the application crash when I select an item so when
the toast and the setText are called.
Do you have any ideas how can I declare my item in the toast and the
setText?


--------------------------------------------------------------------------------------------------------
 
((ImageButton)findViewById(R.id.pickPays)).setOnClickListener(new
OnClickListener(){

            public void onClick(View v) {

                AlertDialog.Builder builder = new
AlertDialog.Builder(Postit.this);
                builder.setTitle("Selectionne ton pays");
                builder.setSingleChoiceItems(R.array.pays, -1, new
DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int
item) {
                        dialog.cancel();
                        Toast.makeText(getApplicationContext(), item ,
Toast.LENGTH_LONG).show();
                        ((TextView)
findViewById(R.id.paysDisplay)).setText(item);
                    }
                });
                AlertDialog alert = builder.create();
                alert.show();

            }
        });

----------------------------------------------------------------------------------------

Thanks in advance,

Florent

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to