How can change adapter for spinner in tabbed app?

SamerAlshurafaSamerAlshurafa USMember
edited August 2015 in Xamarin.Android

Hi ..
I would change spinner adapter if user switch the tab ..
spinner contain images
I use Fragment

ex.

public class class1 : Fragment
{
....

Spinner S1 = view.FindViewById(Resource.Id.S1);
S1.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_s1_ItemSelected);
var myAdapter_S1 = new MyAdapterS1(Activity); // I use MyAdapterS1 --> to show 5 images
S1.Adapter = myAdapter_S1;
....
}

public class class2 : Fragment
{
....

Spinner S1 = view.FindViewById(Resource.Id.S1);
S1.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_s1_ItemSelected);
var myAdapter_S2 = new MyAdapterS2(Activity); // I use MyAdapterS2 --> to show 4 images
S1.Adapter = myAdapter_S2;
....
}

The emulator shows exception and end the app
So what the answer ....

my regards :)

Best Answer

Answers

  • CheesebaronCheesebaron DKInsider, University mod

    Do we need to guess the exception?

  • No ..
    the problem is the emulator doesn't show the exceptions information and I can't show it , I don't know ..

  • CheesebaronCheesebaron DKInsider, University mod

    Uhm yes it does, if you get the dialog with saying "Unhandled exception" with a blank field under it and continue and break button. Press continue and the exception will appear in the output window eventually.

    Alternatively enable breaking on exceptions in your IDE.

  • Doesn't show any error .. what I must do ?

  • CheesebaronCheesebaron DKInsider, University mod

    Press Ctrl+W then O or go to View > Press Output

    In the dialog you get when you get the exception, keep pressing continue. The stack trace will spill out in the output window.

    How have you even been debugging your apps until now?

  • this you mean ..

  • Thanks very much :)
    I found the problem .. I missed declare view ...

Sign In or Register to comment.