Xamarin.Forms实施AndHud和BTProgressHud [英] Xamarin.Forms implement AndHud and BTProgressHud

查看:887
本文介绍了Xamarin.Forms实施AndHud和BTProgressHud的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以点我一个Xamarin.forms样本,利用AndHud Android和BTProgressHud为iOS(或类似的话)?

Can anyone point me to a Xamarin.forms sample that utilises AndHud for Android and BTProgressHud for iOS (or anything similar)?

我知道是这里的ACR-Xamarin窗体的例子 https://github.com/ aritchie / ACR-xamarin表单的,但它是太复杂,完全在我的头上。

I know there is the ACR-Xamarin-Forms example here https://github.com/aritchie/acr-xamarin-forms, but it is way too complicated and completely over my head.

当然,还有一个更简单的容易理解的实现,但是如果指导不是如何获得实现它(对于C#和Xamarin新手)开始某种

Surely there is a more simple easy to understand implementation, but if not some sort of guidance on how to get started on implementing it (for a C# and Xamarin newbie)

在此先感谢

推荐答案

这是如何我已经做到了为iOS。所有你需要做的工作为Android是创建IHud的,使用的,而不是BTProgressHud AndHud的实现。

This is how I've done it for iOS. All you should need to do for Android is create an implementation of IHud that using AndHud instead of BTProgressHud.

首先,在共享项目建立的接口

First, create an interface in the shared project

public interface IHud
{
    void Show();
    void Show(string message);
    void Dismiss();
}

接着,在iOS的项目,使用BTProgressHud组件创建IHud的实施方案:

Next, in the iOS project, create an implementation of IHud using BTProgressHud component:

[assembly: Dependency(typeof(Hud))]
namespace project.iOS
{
    public class Hud : IHud
    {
        public Hud ()
        {
        }

        public void Show() {
            BTProgressHUD.Show ();
        }

        public void Show(string message) {
            BTProgressHUD.Show (message);
        }

        public void Dismiss() {
            BTProgressHUD.Dismiss ();
        }
    }
}

最后,从形式code利用这一点,只是做

Finally, to utilize this from Forms code, just do

    var hud = DependencyService.Get<IHud> ();
    hud.Show ("Loading Vehicles");

    // tasks...

    hud.Dismiss ();

这篇关于Xamarin.Forms实施AndHud和BTProgressHud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆