Sunday, July 10, 2011

[android-developers] Loading an array of strings into a ListView

I'm trying to load a String[] array into a ListView. Based on
examples I've seen, I *THINK* this (below) is how to do it...but
I'm far from certain.

// This part I'm familiar with....
String[] nameList = getResources().getStringArray(R.array.Grains_Names);

// The rest of this is new ground for me
gList = (ListView)findViewById(R.id.namelist);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.id.namelist);

nameList.setAdapter(adapter);
registerForContextMenu(nameList);

Am I even close to getting this right?

Thanks,
--jim

--
73 DE N5IAL (/4) | "Now what *you* need is a proper pint of
spooky130u@gmail.com | porter poured in a proper pewter porter
< Running FreeBSD 7.0 > | pot.."
ICBM / Hurricane: | --Peter Dalgaard in alt.sysadmin.recovery
30.44406N 86.59909W |

Point Lobos Photography Set 1 (Photo-posters): http://jdgapps.com

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate