0

我想在单击按钮时显示加载提示,我该怎么做?

protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);

        // Get our button from the layout resource,
        // and attach an event to it
        Button button = FindViewById<Button>(Resource.Id.MyButton);
        objListView = FindViewById<ListView>(Resource.Id.listView1);
        button.Click += button_Click;
    }

    void button_Click(object sender, EventArgs e)
    {
     //in this place i get RSS list from web ,this process take a minute 
    }
4

1 回答 1

0

首先,您需要添加一个变量来加载进度

private ProgressDialog progress;

protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            Button button = FindViewById<Button>(Resource.Id.MyButton);
            objListView = FindViewById<ListView>(Resource.Id.listView1);

            button.Click += (s, e) => {
                Action act = new Action(YOUR METHOD NAME);
                progress = new ProgressDialog(this);
                progress.SetTitle("loading...");
                progress.Show();

                act.BeginInvoke(a => act.EndInvoke(a), null);
            };
        }

并且在您的方法中,您必须取消加载进度

progress.Dismiss();
于 2012-11-04T06:04:39.743 回答