On Apr 19, 2012, at 5:33 AM, cmdrew wrote:
> I'm having an issue with a spinner placed within a PopupWindow in that when I
> try to show the items in the spinner, I get an Android Force Close.  I have
> reproduced in a very simple 'Hello World' project and really can't see why
> there should be an issue.  Doesn't appear to be anything in the Android log
> to explain...

(For future reference, small attachments should be able to go to the list...)

Indeed, very annoying. I don't know why it's crashing, but stackoverflow's 
wisdom appears to be "use a Dialog, not a PopupWindow" (in that I've had no 
success finding a Java sample which uses both Spinner and PopupWindow), and 
Dialog works:

        void button_Click(object sender, EventArgs e)
        {
                LayoutInflater li = 
(LayoutInflater)GetSystemService(Android.Content.Context.LayoutInflaterService);
                View layout = li.Inflate(Resource.Layout.popup, null, false);

                Spinner spinner = 
layout.FindViewById<Spinner>(Resource.Id.spinner);

                var adapter = ArrayAdapter.CreateFromResource(this, 
Resource.Array.planets_array, Android.Resource.Layout.SimpleSpinnerItem);
                
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

                spinner.Adapter = adapter;

                var b = new AlertDialog.Builder(this);
                b.SetView (layout);
                var d = b.Create();
                d.Show();
        }

Thanks,
 - Jon

_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to