Asynchronous method to update UI element in Xamarin
I got an app to call api in my server for loading the data. This make sense to use asynchronous methods for loading the data. I don't want the whole UI is locked for waiting the data. But I found
model.GetData().ContinueWith((items) =>
{
list.ItemSource= items;
});
It won't works. I found the reason is all Asynchronous methods are executed by a different thread. You have to call UI main thread to bind the data to UI.
model.GetData().ContinueWith((items) =>
{
evice.BeginInvokeOnMainThread(() =>
{
list.ItemSource= items;
});
});;
[Xamarin Error]:Exception in thread "main" deployment fail
After I installed Facebook SDK for Andorid. I found I cannot deploy my app in the debug anymore. I clicked the play button in Visual Studio, no compilation errors at all. Visual Studio is only freezed in "Deploying in [Phone Name]" for a little white. Then it stoped and gave out this error message,'Exception in thread "main"'. After I did a number of random search in Google, I found some people in the Xamarin Forum mentioned they need to increase the heap size to 1G after installing Facebook SDK. Finally, I increased the heap size to 1G in (Project Properties -> Android Options->Advanced-> Java Max Heap Size). Then it works!
[Xamarin Error]:System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found.
After I switched my Xamarin Forms app from Normal Form Activity to FormsAppCompatActivity. This can provide more function in Material Design, such as TextInputLayout. But I got this error:System.MissingMethodException: Method 'Android.Support.V4.Widget.DrawerLayout.AddDrawerListener' not found. I found the problem is from the libraries. After I updated the latest Xamarin Forms Library in Android Project. That works!
[Xamarin] Error: No xmlns declaration for prefix "local"
I got an error when I built my application. The error said 'No xmlns declaration for prefix "local". Because I used the xaml, I found the compiler did not check the error in xaml file. As a result, it got the runtime error like. This is very easy to solve. Please search all xaml files you used local has this xmlns:local="clr-namespace:[your namespace]"
[Xamarin] Error: AppData\Local\Xamarin\[packages]\[version]\class.jar missing
After I had installed a new component in my Xamarin project, I got an error like that: C:\Users\[username]\ AppData\Local\Xamarin\[packages]\[version]\class.jar missing.
I found the problems are caused the downloading packages are failed before. The Xamarin is not smart enough to re-download automatic.
The solution is simply. I only need to delete all zip files under Error: C:\Users\[username]\AppData\Local\Xamarin\zips and the package folder in the error message. Then I need to rebuild the project. The packages will be download again. The project will build successfully.