1
I need to create a "Loading" when I click on a search button for JSON information on a site. Loading needs to be in the middle of the screen.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FoodSuppy.Tela.PesquisaCidade">
<AbsoluteLayout>
<StackLayout BackgroundColor="Bisque">
<StackLayout HorizontalOptions="CenterAndExpand"
BackgroundColor="HotPink">
<!-- Pesquisa -->
<SearchBar x:Name="MainSearchBar"
SearchButtonPressed="MainSearchBar_OnSearchButtonPressed"
Placeholder="Digite o nome da cidade..."
TextColor="Black"/>
</StackLayout>
<StackLayout BackgroundColor="Aqua">
<ListView x:Name="lstCidade"
HasUnevenRows="True">
<ListView.ItemTemplate>
<!-- DataTemplate = exibe dados de uma coleção de objetos em um ListView -->
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding IBGE}"
TextColor="Blue"
FontSize="0"
HorizontalOptions="Start"/>
<Label Text="{Binding CIDADE}"
TextColor="Blue"
FontSize="Large"
HorizontalOptions="End"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<!-- Loading -->
<StackLayout x:Name="LoadingStack"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
AbsoluteLayout.LayoutFlags="All"
Opacity="0.5"
HeightRequest="500">
<!-- Loading -->
<ActivityIndicator x:Name="actInd"
Color="Blue"
HeightRequest="20"
WidthRequest="20"
BackgroundColor="Transparent"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand">
</ActivityIndicator>
</StackLayout>
</StackLayout>
</AbsoluteLayout>
</ContentPage>