public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = (View) inflater.Inflate(Resource.Layout.GuZhangPuTongSouSUoJieGuo,container, false); Activity.Window.SetSoftInputMode (SoftInput.AdjustPan); mHuoJingLiShiListView = view.FindViewById<ListView> (Resource.Id.HuoJingLiShiChaXunJieGuo_listViewGZJG); mHeaderDanWeiMingCheng = view.FindViewById<TextView> (Resource.Id.txtHeaderDanWeiMingChengChaXunGZJG); mBtnHuoJingLiShiLastPage = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiChaXunJieGuoLastPageGZJG); mBtnHuoJingLiShiNextPage = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiChaXunJieGuoNextPageGZJG); mTxtHuoJingLiSHiPageToGo = view.FindViewById<EditText> (Resource.Id.txtHuoJingLiShiChaXunJieGuoPageToGoGZJG); mbtnHuoJingLiSHiPageToGo = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiChaXunJieGuoPageToGoGZJG); mProgressBar = view.FindViewById<ProgressBar> (Resource.Id.progressBar); mProgressBar.Visibility = ViewStates.Visible; if (logInDialogCreate.mLoginInfo.dwmc.Length > 8) { mHeaderDanWeiMingCheng.Text = logInDialogCreate.mLoginInfo.dwmc.Substring (0, 8); } else { mHeaderDanWeiMingCheng.Text = logInDialogCreate.mLoginInfo.dwmc; } SouSuoTiaoJian1 = view.FindViewById<TextView> (Resource.Id.ChaXunJieGuoTiaoJian1GZJG); SouSuoTiaoJian2 = view.FindViewById<TextView> (Resource.Id.ChaXunJieGuoTiaoJian2GZJG); SouSuoTiaoJian3 = view.FindViewById<TextView> (Resource.Id.ChaXunJieGuoTiaoJian3GZJG); SouSuoTiaoJian4 = view.FindViewById<TextView> (Resource.Id.ChaXunJieGuoTiaoJian4GZJG); switch (GuZhangJiBie) { case "3": SouSuoTiaoJian1.Text ="故障级别:"+ "普通故障"; break; case "4": SouSuoTiaoJian1.Text ="故障级别:"+ "屏蔽信息"; break; } if (GuZhangDiZhi != "") { SouSuoTiaoJian2.Text = "故障地址:" + GuZhangDiZhi; } else { SouSuoTiaoJian2.Text = "故障地址:" + "全部"; } if (BeginTime != "") { BeginTimeString = BeginTime.Replace ("年", "-").Replace ("月", "-").Replace ("日", ""); dateBegin = BeginTimeString; } else { BeginTimeString="全部"; dateBegin = ""; } if (EndTime != "") { EndTimestring = EndTime.Replace ("年", "-").Replace ("月", "-").Replace ("日", ""); dateEnd = EndTimestring; } else { EndTimestring="全部"; dateEnd = ""; } SouSuoTiaoJian3.Text ="开始时间:" + BeginTimeString; SouSuoTiaoJian4.Text ="结束时间:" + EndTimestring; animationfadeIn = new AlphaAnimation(0.0f, 1.0f); animationfadeIn.Duration=500; animationfadeout = new AlphaAnimation(1.0f, 0.0f); animationfadeout.Duration=500; animationfadeout.StartOffset=500; mWorker=new BackgroundWorker(); mWorker.WorkerSupportsCancellation = true; mWorker.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { HttpRequestLiSHi (pageNum); } }; mWorker.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { //work complete if (internetFlag == 1) { mHuoJingLiShiAdapter = new GuZhangLiShiAdapter(Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mHuoJingLiShiChaXunJieGuoList); mHuoJingLiShiListView.Adapter = mHuoJingLiShiAdapter; mHuoJingLiShiListView.StartAnimation (animationfadeIn); if(mHuoJingLiShiAdapter.Count==0) { Toast mToast = Toast.MakeText (Application.Context, "没有历史记录", ToastLength.Short); mToast.Show (); } } else{ Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pausefor1Sec(); }; mWorker2.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker2.RunWorkerAsync(); }; if (mWorker.IsBusy != true) { mWorker.RunWorkerAsync (); } mHuoJingLiShiListView.ItemClick += mHuoJingLiShiListView_ItemClick; mBtnHuoJingLiShiLastPage.Click+= MBtnHuoJingLiShiLastPage_Click; mBtnHuoJingLiShiNextPage.Click += MBtnHuoJingLiShiNextPage_Click; mbtnHuoJingLiSHiPageToGo.Click+= MbtnHuoJingLiSHiPageToGo_Click; return view ; }
void MBtnHuoJingLiShiNextPage_Click(object sender, EventArgs e) { mHuoJingLiShiListView.Enabled = false; if (mHuoJingLiShiChaXunJieGuoList.Count == 0) { //toast Toast mToast = Toast.MakeText (Application.Context, "没有下一页了", ToastLength.Short); mToast.Show (); } else { if (pageNum.ToString() == mHuoJingLiShiChaXunJieGuoList [0].maxPageNum) { //toast Toast mToast = Toast.MakeText (Application.Context, "没有下一页了", ToastLength.Short); mToast.Show (); } else { mProgressBar.Visibility = ViewStates.Visible; mWorkerLast = new BackgroundWorker (); mWorkerLast.WorkerSupportsCancellation = true; mWorkerLast.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { pageNum++; HttpRequestLiSHi (pageNum); } }; mWorkerLast.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { //work complete if (internetFlag == 1) { mHuoJingLiShiListView.StartAnimation (animationfadeout); mHuoJingLiShiAdapter = new GuZhangLiShiAdapter(Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mHuoJingLiShiChaXunJieGuoList); mHuoJingLiShiListView.Adapter = mHuoJingLiShiAdapter; mHuoJingLiShiListView.StartAnimation (animationfadeIn); } else{ Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } mHuoJingLiShiListView.Enabled = true; } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pausefor1Sec(); }; mWorker2.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker2.RunWorkerAsync(); }; if (mWorkerLast.IsBusy != true) { mWorkerLast.RunWorkerAsync (); } } } }
void MbtnHuoJingLiSHiPageToGo_Click(object sender, EventArgs e) { mHuoJingLiShiListView.Enabled = false; InputMethodManager inputManager = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService); inputManager.HideSoftInputFromWindow(mTxtHuoJingLiSHiPageToGo.WindowToken, HideSoftInputFlags.None); if (mTxtHuoJingLiSHiPageToGo.Text == null) { Toast mToast = Toast.MakeText (Application.Context, "请输入页码", ToastLength.Short); mToast.Show (); } else { if (mHuoJingLiShiChaXunJieGuoList.Count == 0) { //toast Toast mToast = Toast.MakeText (Application.Context, "无此页", ToastLength.Short); mToast.Show (); } else { int result; if (isNumberic (mTxtHuoJingLiSHiPageToGo.Text, out result)) { if ((result < Convert.ToInt32(mHuoJingLiShiChaXunJieGuoList [0].maxPageNum))&&(result>0)) { //跳转 mProgressBar.Visibility = ViewStates.Visible; mWorkerPageToGo = new BackgroundWorker (); mWorkerPageToGo.WorkerSupportsCancellation = true; mWorkerPageToGo.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { pageNum=result; HttpRequestLiSHi (result); } }; mWorkerPageToGo.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { //work complete if (internetFlag == 1) { mHuoJingLiShiListView.StartAnimation (animationfadeout); mHuoJingLiShiAdapter = new GuZhangLiShiAdapter(Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mHuoJingLiShiChaXunJieGuoList); mHuoJingLiShiListView.Adapter = mHuoJingLiShiAdapter; mHuoJingLiShiListView.StartAnimation (animationfadeIn); } else{ Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } mHuoJingLiShiListView.Enabled = true; } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pausefor1Sec(); }; mWorker2.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker2.RunWorkerAsync(); }; if (mWorkerPageToGo.IsBusy != true) { mWorkerPageToGo.RunWorkerAsync (); } } else { Toast mToast = Toast.MakeText (Application.Context, "页码超出范围", ToastLength.Short); mToast.Show (); } } else { Toast mToast = Toast.MakeText (Application.Context, "请输入数字", ToastLength.Short); mToast.Show (); } } } mTxtHuoJingLiSHiPageToGo.Text=null; mTxtHuoJingLiSHiPageToGo.ClearFocus (); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = (View) inflater.Inflate(Resource.Layout.GuZhangLiShi_ListShow,container, false); Activity.Window.SetSoftInputMode (SoftInput.AdjustPan); SetHasOptionsMenu(true); mGuZhangLiShiListView = view.FindViewById<ListView> (Resource.Id.HuoJingLiShi_listViewGZ); mHeaderDanWeiMingChengGuZhang = view.FindViewById<TextView> (Resource.Id.txtHeaderDanWeiMingChengGZ); mBtnGuZhangLiShiLastPage = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiLastPageGZ); mBtnGuZhangLiShiNextPage = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiNextPageGZ); mTxtGuZhangLiSHiPageToGo = view.FindViewById<EditText> (Resource.Id.txtHuoJingLiShiPageToGoGZ); mbtnGuZhangLiSHiPageToGo = view.FindViewById<Button> (Resource.Id.btnHuoJingLiShiPageToGoGZ); mProgressBar = view.FindViewById<ProgressBar> (Resource.Id.progressBar); mProgressBar.Visibility = ViewStates.Visible; if (logInDialogCreate.mLoginInfo.dwmc.Length > 8) { mHeaderDanWeiMingChengGuZhang.Text = logInDialogCreate.mLoginInfo.dwmc.Substring (0, 8); } else { mHeaderDanWeiMingChengGuZhang.Text = logInDialogCreate.mLoginInfo.dwmc; } animationfadeIn = new AlphaAnimation(0.0f, 1.0f); animationfadeIn.Duration=500; animationfadeout = new AlphaAnimation(1.0f, 0.0f); animationfadeout.Duration=500; animationfadeout.StartOffset=500; mWorker=new BackgroundWorker(); mWorker.WorkerSupportsCancellation = true; mWorker.DoWork+= delegate(object sender1, DoWorkEventArgs e1) { BackgroundWorker mworker = sender1 as BackgroundWorker; if (mworker.CancellationPending == true) { e1.Cancel = true; } else { HttpRequestLiSHi (pageNum); } }; mWorker.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) { if (e1.Cancelled == true) { } else if (!(e1.Error == null)) { } else { //work complete if (internetFlag == 1) { mGuZhangLiShiAdapter = new GuZhangLiShiAdapter (Application.Context, Resource.Layout.HuoJingLiShiXinXI_Row, mGuZhangLiShiList); mGuZhangLiShiListView.Adapter = mGuZhangLiShiAdapter; mGuZhangLiShiListView.StartAnimation (animationfadeIn); if(mGuZhangLiShiAdapter.Count==0) { Toast mToast = Toast.MakeText (Application.Context, "没有历史记录", ToastLength.Short); mToast.Show (); } } else{ Toast mToast = Toast.MakeText (Application.Context, "网络异常", ToastLength.Short); mToast.Show (); } } BackgroundWorker mWorker2 = new BackgroundWorker (); mWorker2.DoWork +=delegate { pausefor1Sec(); }; mWorker2.RunWorkerCompleted += delegate { mProgressBar.Visibility = ViewStates.Gone; }; mWorker2.RunWorkerAsync(); }; if (mWorker.IsBusy != true) { mWorker.RunWorkerAsync (); } mGuZhangLiShiListView.ItemClick += mHuoJingLiShiListView_ItemClick; mBtnGuZhangLiShiLastPage.Click+= MBtnHuoJingLiShiLastPage_Click; mBtnGuZhangLiShiNextPage.Click += MBtnHuoJingLiShiNextPage_Click; mbtnGuZhangLiSHiPageToGo.Click+= MbtnHuoJingLiSHiPageToGo_Click; return view ; }