Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Is it possible to have a List of available activities to get one of them from this list using fabric

I trying to port app from WinCE to Xamarin.Android. This app is using states machine to switch between states (by user clicking or particular background processing). Every state has own view.
So, main idea is to keep in some provider all available views as List and show one of them by state switching. It might be activated from both UI thread or Worker thread. As the following:

public List<IView> Views { get; protected set; }
public virtual void Init()
{
    Views.Add(new MasterView());
    Views.Add(new LoginView());
    Views.Add(new MainMenuView());
}
public T GetView<T>() where T : InView
{
    return (T)Views.FirstOrDefault(view => view is T);
}

Every activity is inherited from base activity class.

[Activity(Label = "MasterView")]
    public class MasterView : BaseView, IMasterView
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
        }
    }

public class BaseView : Activity, IView  //is in class library project
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.baseview);
        }
    }

Now, when Init method starts to add new MasterView i'm getting error "Java.Lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()"

All this stuff works like a charm under WinCE.
Will it work at Xamarin.Android? How to modify it?

Best Answer

Answers

Sign In or Register to comment.