Looks like according to the documentation
http://developer.android.com/reference/android/widget/ArrayAdapter.html
ArrayAdapter needs to reference a TextView where it looks like you are
giving it the ID of a spinner.

-E

On Jun 7, 9:44 pm, scadaguru <[email protected]> wrote:
> I am trying to add a string dynamically on button click but it force
> closes every time.
> Any help is appreciated please.
>
>         String[] mStrings = {
>                 "Abbaye de Belloc", "Abbaye du Mont des Cats",
> "Abertam", "Abondance", "Ackawi",
>                 "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l
> Pitu", "Airag", "Airedale",
>                 "Aisy Cendre", "Allgauer Emmentaler", "Alverca",
> "Ambert", "American Cheese",
>                 "Ami du Chambertin", "Anejo Enchilado", "Anneau du Vic-
> Bilh", "Anthoriro", "Appenzell"
>         };
>
>         ArrayAdapter<String> myArr;
>
>         myArr = new ArrayAdapter<String>(this,
> android.R.layout.simple_spinner_dropdown_item, mStrings);
>
>         Spinner s1 = (Spinner) findViewById(R.id.Spinner01);
>         s1.setAdapter(myArr);
>
>         myAddBtn.setOnClickListener(new View.OnClickListener() {
>             public void onClick(View v) {
>                 //showToast("Just before add");
>                 myArr.insert("Added string");
>             }});

-- 
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