Giter Club home page Giter Club logo

consume-a-json-api-using-xamarin.forms's Introduction

Consume-a-JSON-API-using-Xamarin.Forms

Example of consuming a JSON API and Local storage (SQLite) using Xamarin.Forms.

On this example you will be able to see a HTTP request and SQLite integration suing Xamarin.Forms for Android and iOS using XAML as UI builder and it also integrate a pull to refresh command for the ListView, it using a public US dollar API to get the currency exchange rate.

Please let me know any issues or concerns.

alt tag

consume-a-json-api-using-xamarin.forms's People

Contributors

15mgm15 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

consume-a-json-api-using-xamarin.forms's Issues

When error ocurred does not work

Hi,

I´m working on an app and I tried to replicated and everything works until my service returns 404 error.

The service throw the exception to ViewModel. The ViewModel throw the exception to View and the View displays the error returned from API.

After that, I swipe down to refresh the page and the code in ViewModel is not executed.

This is the constructor code in View class:
`
public Menu()
{
InitializeComponent();
try
{
this.token = PropertiesOperations.GetTokenProperties();
//show Name
if (this.token.FullName != null)
lblFullName.Text = "Ing. " + this.token.FullName;

            BindingContext = viewModel;
            viewModel = new ProjectViewModel(this.token.UserIDCRM);
        }
        catch (Exception ex)
        {
            Device.BeginInvokeOnMainThread(async () =>
            {
                await this.DisplayAlert("Error", ex.InnerException.Message, "OK");
            });
        }
    }`

This is XAML code:
<StackLayout Orientation="Vertical"> <StackLayout Orientation="Horizontal" Margin="0,0,0,50"> <Label HorizontalTextAlignment="Center" x:Name="lblFullName" HorizontalOptions="CenterAndExpand" FontAttributes="Bold" TextColor="Black" FontSize="16"/> </StackLayout> <ListView x:Name="ProjectsList" ItemsSource="{Binding ProjectsList}" ItemTapped="ListView_ItemTapped" IsPullToRefreshEnabled="true" RefreshCommand="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}"> <ListView.ItemTemplate> <DataTemplate> <TextCell Text="{Binding idProject}" Detail="{Binding description}" TextColor="Black"></TextCell> </DataTemplate> </ListView.ItemTemplate> </ListView> <ActivityIndicator HorizontalOptions="Center" x:Name="actLoading" IsVisible="{Binding IsRefreshing}" IsRunning="{Binding IsRefreshing}" Color="#1360ad"/> </StackLayout>

It's weird. If the API returns data everything works perfectly.

Have you ever have any situation like this?

Thanks so much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.