TreKing wrote: > On Tue, Feb 16, 2010 at 12:37 AM, Chirayu Dalwadi > <[email protected] <mailto:[email protected]>> wrote: > > Hey TreKing, Can u show the code? > > > Well, I _could_ ... but this is very straightforward so I leave it as > an exercise to the reader =P. > > I assume you have a Spinner, it's adapter, and an OnClickListener set up > for the Spinner. Let's say it's showing a list of strings. Then just add > a string "Make your selection..." as the first item in the adapter and > check for index == 0 in the click listener and do nothing in that case. > > If your list of objects is more complicated then strings (as is my > case), then it gets a little trickier, but not too bad. For example, if > you have a custom Color object with a toString() method that returns the > name ("Red", "Blue", etc). you would just make a dummy Color object with > it's name set to "Choose a color..." and add that as your first object.
You could also make a wrapping adapter if you cannot easily put the "hint" object into your main adapter (e.g., it's a SimpleCursorAdapter from a database query). I haven't tried my MergeAdapter with a Spinner, though even if the code does not directly work, the principles behind it should still hold up: http://github.com/commonsguy/cwac-merge -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 2.9 Available! -- 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

