The second parameter to ArrayAdapter is a layout resource id, which is
the template for list items.
It has to be an R.layout value, e.g. R.layout.my_item_layout, where
my_item_layout.xml is a layout file under "res".
The third parameter is a view id, within that layout.
If you would like to instantiate your item layouts dynamically, then
don't use ArrayAdapter: subclass BaseAdapter instead, override getView,
and do "new LinearLayout" or whatever when "convertView == null".
-- Kostya
08.07.2011 21:34, Raúl Do Santos ?????:
Exactly but the issue is that my app strictly must declare the UI only
in javacode, then the problem is that I can not access the elements
created dynamically by their id, if i do: LinearLayout ll =
findViewById(R.id.layoutSpinner); ll is null.
If you know other way of access the elements created dynamically i'll
be grateful
2011/7/8 TreKing <[email protected] <mailto:[email protected]>>
On Fri, Jul 8, 2011 at 11:09 AM, Raúl Do Santos
<[email protected] <mailto:[email protected]>> wrote:
when i create an arrayadapter, like this:
ArrayAdapter<entity> adapter = new ArrayAdapter<entity> (
this, R.id.layoutSpinner, R.id.item, list);
R.id.layoutSpinner and R.id.item are declarated within
strings.xml, but are instatiated dinammically and setted ids
like this:
LinearLayout layoutSpinner = new LinearLayout ();
layoutSpinner.setId(R.id.layoutSpinner);
I believe R.id.layoutSpinner should refer to an XML layout that
will populate a list.
R.id.item should refer to the ID of a TextView within
R.id.layoutSpinner that will be filled with the text information
coming from the items in the list.
Defining either of these in strings.xml doesn't make sense.
What are you actually trying to do?
-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> -
Chicago transit tracking app for Android-powered devices
--
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]
<mailto:[email protected]>
To unsubscribe from this group, send email to
[email protected]
<mailto:android-developers%[email protected]>
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
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
--
Kostya Vasilyev
--
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