protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.ActionBar); SetContentView(Resource.Layout.Index1); Display display = this.WindowManager.DefaultDisplay; this.mDeviceHeight = display.Height; this.mDeviceWidth = display.Width; ColorDrawable color = new ColorDrawable(Color.OrangeRed); this.ActionBar.SetBackgroundDrawable(color); //http://eggeggss.ddns.net/sse/Request.aspx?catelog=GetBarCodeItem List <Item> list = new List <Item>(); list.Add(new Item() { Descrip = "DevExpress", Link = "https://www.devexpress.com/" }); list.Add(new Item() { Descrip = "Xamarin", Link = "https://www.xamarin.com/" }); list.Add(new Item() { Descrip = "Microsoft", Link = "https://www.microsoft.com/zh-cn" }); list.Add(new Item() { Descrip = "百度雲", Link = "https://login.bce.baidu.com/" }); list.Add(new Item() { Descrip = "小米官網", Link = "http://www.mi.com/tw/events/school831/" }); list.Add(new Item() { Descrip = "奇摩", Link = "http://www.yahoo.com.tw" }); // list.Add(new Item() { Descrip = "Xpage測試報表", Link = "http://arc-ap2.arcadyan.com.tw/GP/VendorReport.nsf/TEST.xsp" }); //list.Add(new Item() { Descrip = "測試報表", Link = "http://eggeggss.ddns.net/notesbarcode/notesservice1.aspx" }); string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); _itemdb = new ItemDB(folder); List <Item> listFromDb = _itemdb.SelectItem(); if (listFromDb.Count == 0) { _itemdb.InsertAllItem(list); listFromDb = _itemdb.SelectItem(); } var listview = this.FindViewById <ListView>(Resource.Id.listview); adapter = new MyList(); adapter.Context = this; adapter.List = listFromDb; adapter.DeviceHeight = this.mDeviceHeight; adapter.DeviceWidth = this.mDeviceWidth; listview.Adapter = adapter; var refresh = this.FindViewById <SwipeRefreshLayout>(Resource.Id.refresher1); refresh.Refresh += async(s1, e1) => { try { String uri = this.AppSetting.WebAPI; if (!(String.IsNullOrEmpty(uri))) { var items = await WebApi.DownloadJsonDataCustom <IEnumerable <Item> >(uri); foreach (var item in items) { _itemdb.InsertItem(item); } } } catch (Exception ex) { Toast.MakeText(this, "下載失敗 " + ex.Message, ToastLength.Short).Show(); //Util.Dialog(this, "Information", "Please Check NetWork Status", null, null); } var dbitems = _itemdb.SelectItem(); adapter.List = dbitems; adapter.NotifyDataSetChanged(); refresh.Refreshing = false; }; // Create your application here }