In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you how to control the display and hiding of activity indicators in Xamarin.Forms, I believe most people still don't know how, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go and find out about it!
Show and hide activity indicators in Xamarin.Forms
In addition to using the IsRunning attribute in XAML, developers can also use the IsRunning attribute in code-behind files to control the display and hiding of indicators. In this case, you first need to define a name for the activity indicator in the XAML file using the x:Name attribute, and then set the IsRunning attribute with the defined name in the code-behind file.
[Example 12-2: ActivityIndicatorIsRunningTwo] The following controls the display and hiding of activity indicators in a code-behind file. The specific operation steps are as follows:
(1) MainPage.xaml file, write code, layout content pages. The code is as follows:
(2) Open the MainPage.xaml.cs file and write code to control the display and hiding of the activity indicator through buttons. The code is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace ActivityIndicatorIsRunningTwo
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
//Display activity indicator
void OnShowActivityIndicator(object sender, EventArgs args)
{
activityIndicator.IsRunning = true;
showButton.IsEnabled = false;
hideButton.IsEnabled = true;
}
//Hide activity indicator
void OnHideActivityIndicator(object sender, EventArgs args)
{
activityIndicator.IsRunning = false;
showButton.IsEnabled = true;
hideButton.IsEnabled = false;
}
}
}
Run the program at this point and see the effects shown in Figures 12.4 - 12.6. When the developer taps the Show Activity Indicator button, the activity indicator is displayed and the activity takes place, similar to what is shown in Figures 12.7 - 12.9.
Figure 12.4 Figure 12.7 Android Figure 12.5 Figure 12.8 iOS Figure 12.6 Figure 12.9 Windows Phone
In addition to directly assigning Boolean values to the IsRunning attribute defined by ActivityIndicator, developers can also assign values to this attribute by means of data binding. In this case, the bound data also returns Boolean types.
[Example 12-3: ActivityIndicatorIsRunningThree] The function of loading network images will be implemented as follows. The code is as follows:
In this code, we bind the ActivityIndicator property to the IsLoading property of Image. Run the program at this point and see the effects shown in Figures 12.10 - 12.12. When the image is loaded, you will see an effect similar to that shown in Figures 12.13 - 12.15.
Figure 12.10 Figure 12.13 Android Figure 12.11 Figure 12.14 iOS Figure 12.12 Figure 12.15 Windows Phone
The above is "How to control the display and hide of activity indicators in Xamarin.Forms". Thank you for reading all the contents of this article! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.