[android-developers] Dynamic ArrayAdapter and Spinner

2010-09-14 Thread Sara Khalatbari
Hi all

I need to create an  ArrayAdapter and a Spinner that are totally dynamic and
have nothing to do with the layout file.

So I am trying to do something like:

Spinner spinnerListID;
spinnerListID = new Spinner (this);
String[] array_spinner = new String[5];
array_spinner[0]=1;
array_spinner[1]=2;
array_spinner[2]=3;
array_spinner[3]=4;
array_spinner[4]=5;
ArrayAdapter adapter = new ArrayAdapter(this, ?, array_spinner);
spinnerListID.setAdapter(adapter);
ll.addView(editTextInputListID);


But I can not see how I can create an ArrayAdapter that does not need
a textViewResourceId?

As it is described
http://developer.android.com/reference/android/widget/ArrayAdapter.html: It
looks like it is a needed constructor parameter.
Or should I not use this way at all?

Thank you,
Sara

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

Re: [android-developers] Dynamic ArrayAdapter and Spinner

2010-09-14 Thread Mark Murphy
On Tue, Sep 14, 2010 at 11:14 AM, Sara Khalatbari saracom...@gmail.com wrote:
 But I can not see how I can create an ArrayAdapter that does not need a
 textViewResourceId?

Subclass ArrayAdapter, override getView(), and you can ignore that
parameter, as it will not get used. It only gets used by the stock
implementation of getView().

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

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