当前位置: 首页>>代码示例>>C#>>正文


C# ListView.IsItemChecked方法代码示例

本文整理汇总了C#中ListView.IsItemChecked方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.IsItemChecked方法的具体用法?C# ListView.IsItemChecked怎么用?C# ListView.IsItemChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListView的用法示例。


在下文中一共展示了ListView.IsItemChecked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreateView

		public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			view = inflater.Inflate(Resource.Layout.weld_condition_fragment, container, false);

			coordinatorLayout = view.FindViewById<CoordinatorLayout>(Resource.Id.coordinator_layout);

			selectedBackGroundColor = Context.Resources.GetColor(Resource.Color.tab3_textview_background);
			listView = view.FindViewById<ListView>(Resource.Id.wcdListView);
			listView.Adapter = wcdListAdapter;
			listView.FastScrollEnabled = false;
			listView.ChoiceMode = ChoiceMode.Multiple;
			listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
			{
				wcdListAdapter[e.Position].ItemChecked = listView.IsItemChecked(e.Position);
				if (listView.IsItemChecked(e.Position)) {
					lastPosition = e.Position;
					e.View.SetBackgroundColor(selectedBackGroundColor);
				} else {
					e.View.SetBackgroundColor(defaultBackgroundColor);  // 기본 백그라운드 색깔
				}

				try {
					if (wcdListAdapter.Count == 0)
						fabWcd.SetImageResource(Resource.Drawable.ic_refresh_white);
					else if (listView.CheckedItemCount == 0)
						fabWcd.SetImageResource(Resource.Drawable.ic_subject_white);
					else
						fabWcd.SetImageResource(Resource.Drawable.ic_edit_white);
				} catch { }

				if (snackbar == null)
					snackbar = Snackbar.Make(coordinatorLayout, listView.CheckedItemCount.ToString() + "개 항목 선택됨", Snackbar.LengthIndefinite)
							.SetAction("선택 취소", (view) => { CheckListItem(); snackbar = null; });
				if (listView.CheckedItemCount > 0) {
					if (snackbar.IsShown)
						snackbar.SetText(listView.CheckedItemCount.ToString() + "개 항목 선택됨");
					else
						snackbar.Show();
				} else if (snackbar != null) {
					snackbar.Dismiss();
					snackbar = null;
				}
			};
			listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) =>
			{
				FabWcd_Click(sender, e);
			};

			var refresher = view.FindViewById<SwipeRefreshLayout>(Resource.Id.srl);
			if (refresher != null) {
				refresher.Refresh += delegate
				{
					Refresh(forced: true);
					refresher.Refreshing = false;
				};
			}

			// 떠 있는 액션버튼
			fabWcd = view.FindViewById<FloatingActionButton>(Resource.Id.fab_wcd);
			fabWcd.Click += (object sender, EventArgs e) =>
			{
				if (listView.CheckedItemCount == 0)
					Pref.TextViewDialog(Context, robotPath);
				else
					FabWcd_Click(sender, e);
			};

			try {
				if (wcdListAdapter.Count == 0)
					fabWcd.SetImageResource(Resource.Drawable.ic_refresh_white);
				else if (listView.CheckedItemCount == 0)
					fabWcd.SetImageResource(Resource.Drawable.ic_subject_white);
				else
					fabWcd.SetImageResource(Resource.Drawable.ic_edit_white);
			} catch { }

			return view;
		}
开发者ID:mcm811,项目名称:Hi5Controller.CSharp,代码行数:78,代码来源:WeldConditionFragment.cs

示例2: OnListItemClick

        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            base.OnListItemClick(l, v, position, id);

            m_DataChanged = true;
            m_AllTasks[position].Checked = l.IsItemChecked(position);

            try
            {
                DataManager.SaveTask(m_AllTasks[position]);
            }
            catch (Exception)
            {
                RunOnUiThread(() => Toast.MakeText(this, Resource.String.unable_to_save,
                                                   ToastLength.Short).Show());

            }

            RunOnUiThread(() => ((TaskAdapter)ListAdapter).NotifyDataSetChanged());
            SetActionBar();
        }
开发者ID:SpiderMaster,项目名称:TasksSimplified,代码行数:21,代码来源:MainActivity.cs


注:本文中的ListView.IsItemChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。