protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Activity_To_Do); CurrentPlatform.Init(); // Create the Mobile Service Client instance, using the provided // Mobile Service URL and key client = new MobileServiceClient(applicationURL, applicationKey); await InitLocalStoreAsync(); // Get the Mobile Service sync table instance to use toDoTable = client.GetSyncTable <ToDoItem> (); textNewToDo = FindViewById <EditText> (Resource.Id.textNewToDo); // Create an adapter to bind the items with the view adapter = new ToDoItemAdapter(this, Resource.Layout.Row_List_To_Do); var listViewToDo = FindViewById <ListView> (Resource.Id.listViewToDo); listViewToDo.Adapter = adapter; // Load the items from the Mobile Service OnRefreshItemsSelected(); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Activity_To_Do); CurrentPlatform.Init(); // Create the client instance, using the mobile app backend URL. client = new MobileServiceClient(applicationURL); #if OFFLINE_SYNC_ENABLED await InitLocalStoreAsync(); // Get the sync table instance to use to store TodoItem rows. todoTable = client.GetSyncTable <ToDoItem>(); #else todoTable = client.GetTable <ToDoItem>(); #endif textNewToDo = FindViewById <EditText>(Resource.Id.textNewToDo); // Create an adapter to bind the items with the view adapter = new ToDoItemAdapter(this, Resource.Layout.Row_List_To_Do); var listViewToDo = FindViewById <ListView>(Resource.Id.listViewToDo); listViewToDo.Adapter = adapter; // Load the items from the mobile app backend. OnRefreshItemsSelected(); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Activity_To_Do); progressBar = FindViewById <ProgressBar> (Resource.Id.loadingProgressBar); // Initialize the progress bar progressBar.Visibility = ViewStates.Gone; // Create ProgressFilter to handle busy state var progressHandler = new ProgressHandler(); progressHandler.BusyStateChange += (busy) => { if (progressBar != null) { progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone; } }; try { CurrentPlatform.Init(); // Create the Mobile Service Client instance, using the provided // Mobile Service URL and key client = new MobileServiceClient( applicationURL, applicationKey, progressHandler); // Get the Mobile Service Table instance to use toDoTable = client.GetTable <ToDoItem> (); textNewToDo = FindViewById <EditText> (Resource.Id.textNewToDo); // Create an adapter to bind the items with the view adapter = new ToDoItemAdapter(this, Resource.Layout.Row_List_To_Do); var listViewToDo = FindViewById <ListView> (Resource.Id.listViewToDo); listViewToDo.Adapter = adapter; // Load the items from the Mobile Service await RefreshItemsFromTableAsync(); } catch (Java.Net.MalformedURLException) { CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error"); } catch (Exception e) { CreateAndShowDialog(e, "Error"); } }