Xamrin上拉加载,下拉刷新mj的用法

有问题qq联系,569653292,不说废话,直接代码

var header = new MJRefreshNormalHeader();

            var footer = new MJRefreshAutoNormalFooter ();
            var footer2 = new MJRefreshBackFooter();
            utv_zx.SetHeader(header);
            utv_zx.SetFooter (footer);
            //footer.BeginRefreshing ();//调用一次加载对方法
            //footer.BackgroundColor = UIColor.Blue;

            //上蜡加载方法
            footer.RefreshingBlock = async () =>
            {
                ziXunSource tableSources=(ziXunSource)this.utv_zx.Source;
                nint insetWhenLine=tableSources.TableCount();
                DataTable dt2=getGps.MoreNewsListIos(10).Tables [0];
                zxImage=new string[dt2.Rows.Count] ;
                zxTime=new string[dt2.Rows.Count] ;
                zxTitle =new string[dt2.Rows.Count] ;
                zxId = new string[dt2.Rows.Count] ;
                for (int i = 0; i < zxId.Length; i++) {
                    zxId [i] = dt2.Rows [i] ["InformationId"].ToString ();
                    zxTime [i] = dt2.Rows [i] ["InformationDate"].ToString ();
                    zxImage [i] = dt2.Rows [i] ["imgUrl"].ToString ();
                    zxTitle [i] = dt2.Rows [i] ["InformationTitle"].ToString ();
                }

                tableSources.TableDataAdd(utv_zx,zxId, zxTitle, zxTime, zxImage);

                //内容刷新
                //Source.Add("TestData : " + r.Next(1000, 10000));    
                await Task.Delay(1000);
                footer.EndRefreshing();
            };
            //下拉刷新方法
            header.RefreshingBlock = async () =>
            {
                //内容刷新
                this.utv_zx.ReloadData();
                //Source.Add("TestData : " + r.Next(1000, 10000));    
                await Task.Delay(1000);
                header.EndRefreshing();
            };
            footer.SetTitle("上拉加载更多!", MJRefreshState.Idle);
            //footer.SetTitle("松开马上加载", MJRefreshState.NoMoreData);
            footer.SetTitle("正在加载,请稍后...", MJRefreshState.Refreshing);

            header.SetTitle("下拉可以刷新!", MJRefreshState.Idle);
            header.SetTitle("松开马上刷新", MJRefreshState.Pulling);
            header.SetTitle("正在刷新,请稍后...", MJRefreshState.Refreshing);

            header.LastUpdatedTimeLabel.Hidden = true;



source

using System;
using UIKit;
using Foundation;
using System.Collections.Generic;
using System.Linq;

namespace lvbao
{
    public class ziXunSource:UITableViewSource
    {
        List<string> ID=new List<string>();
        List<string> ziXunTitle=new List<string>();
        List<string> ziXunTime=new List<string>();
        List<string> ziXunImage=new List<string>();
        /*public List<string> TableDataID{
            get{return ID;}
            private set{ID.Add (value);}
        }*/
        public nint TableCount()
        {
            return ID.Count; 
        }
        public void TableDataAdd(UITableView tableView,string[] id,string[] zixuntitle,string[] zixuntime,string[] zixunimage)
        {
            for (int i = 0; i < id.Length; i++) {
                ID.Add (id[i]);
                ziXunTitle.Add (zixuntitle[i]);
                ziXunTime.Add(zixuntime[i]);
                ziXunImage.Add(zixunimage[i]);
                tableView.InsertRows(new NSIndexPath[] {
                    NSIndexPath.FromRowSection(ID.Count-1,0)
                },UITableViewRowAnimation.Automatic);
            }
        }
        //string[] ID,ziXunTitle,ziXunTime,ziXunImage;
        //private String CellIdentifier="CustomCell";
        NSString CellIdentifier1= new NSString("Customcell");
        UIViewController pub_this;
        public ziXunSource (UIViewController pubthis,string[] id,string[] zixuntitle,string[] zixuntime,string[] zixunimage)
        {
            pub_this =    pubthis;
            /*for (int i = 0; i < id.Length; i++) {
                ID.Add (id[i]);
                ziXunTitle.Add (zixuntitle[i]);
                ziXunTime.Add(zixuntime[i]);
                ziXunImage.Add(zixunimage[i]);
            }*/
            ID = id.ToList();
            ziXunTitle = zixuntitle.ToList();
            ziXunTime = zixuntime.ToList();
            ziXunImage = zixunimage.ToList();
            //ziXunTime.push (1);
        }

        public override nint RowsInSection (UITableView tableview, nint section)
        {
            return ID.Count;
        }
        /*public override string TitleForHeader (UITableView tableView, nint section)
        {
            return "表示这是历史订单记录";
        }
        public override nfloat GetHeightForHeader (UITableView tableView, nint section)
        {
            return -20;
        }
        */
        //public 
        public override nfloat GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
        {
            return 128;
        }
        public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
        {
            
            //var cell = tableView.DequeueReusableCell (CustomCell.CELLID)as CustomCell;
            //CustomCell cell = (CustomCell)tableView.DequeueReusableCell (CustomCell.CELLID);
            var cell = tableView.DequeueReusableCell (CellIdentifier1) as ziXunCell;
            //var cell=tableView.DequeueReusableCell (CellIdentifier1);
            if (cell == null) {
                cell = new ziXunCell (CellIdentifier1);
                //cell=new UITableViewCell (UITableViewCellStyle.Default,CellIdentifier1);
                //cell.ziXunTime.Text = ziXunTitle [indexPath.Row];
                cell.UpdateCell (ID[indexPath.Row].ToString(),ziXunImage[indexPath.Row].ToString(),ziXunTitle[indexPath.Row].ToString(),ziXunTime[indexPath.Row].ToString());
            }
            return cell;
        }
        //选取行
        public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
        {
            int rowindex = indexPath.Row;
            ziXunDetailController yiwan = new ziXunDetailController ();
            UITableViewCell cellview = tableView.CellAt (indexPath);

            //cellview[0]["ziXunTitle"];
            yiwan.NavigationItem.Title=((ziXunCell)cellview).id;
            pub_this.NavigationController.PushViewController (yiwan, true);
        } 
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值