• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ListView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: OnCreate

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

            // Set our view from the "main" layout resource

            SetContentView(Resource.Layout.Main);

            setupParent(FindViewById<LinearLayout>(Resource.Id.mainLayout));
            listViewGoodsMain = FindViewById<ListView>(Resource.Id.listViewGoodsMain);

            goodsItemsList = new List<GoodsItem>();
            goodsItemsList.Add(new GoodsItem() { Id = 1, Quantity = 1, Name = "Пельмешки"});
            goodsItemsList.Add(new GoodsItem() { Id = 2, Quantity = 2, Name = "Сосисоны" });

            myGoodsItemsAdapter = new GoodsItemsAdapter(this, goodsItemsList);
            listViewGoodsMain.Adapter = myGoodsItemsAdapter;

            var emptyText = FindViewById<TextView>(Resource.Id.textViewGoodsListEmpty);
            listViewGoodsMain.EmptyView = emptyText;

            editTextNewProduct = FindViewById<EditText>(Resource.Id.EditTextNewProduct);
            editTextNewProduct.EditorAction += editTextNewProduct_EditorAction;
            editTextNewProduct.Click += editTextNewProduct_Click;

            checkBoxRed = FindViewById<CheckBox>(Resource.Id.checkBoxRed);
            checkBoxRed.Click += checkBoxRed_Click;
        }
开发者ID:TkachenkoRoman,项目名称:GoodsListApp,代码行数:28,代码来源:MainActivity.cs


示例2: OnListItemClick

        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            var url = _adapter.GetMapUrl (position);
            var intent = new Intent (Intent.ActionView, Uri.Parse(url));

            StartActivity (intent);
        }
开发者ID:bozood,项目名称:MobileDay,代码行数:7,代码来源:CoffeeListActivity.cs


示例3: OnCreateView

		public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			// Use this to return your custom view for this Fragment
			// return inflater.Inflate(Resource.Layout.YourFragment, container, false);

			//	  Lich hoc theo HK
			var rootView = inflater.Inflate (Resource.Layout.LichHoc_HK, container, false);
			isfirst = true;
			listView_HK = rootView.FindViewById<ListView> (Resource.Id.listLH);
			lbl_HK = rootView.FindViewById<TextView> (Resource.Id.lbl_HK_LH);
			lbl_NH = rootView.FindViewById<TextView> (Resource.Id.lbl_NH_LH);
			progress = rootView.FindViewById<ProgressBar> (Resource.Id.progressLH);
			linear = rootView.FindViewById<LinearLayout>(Resource.Id.linear_HK_LH);
			linearLH = rootView.FindViewById<LinearLayout>(Resource.Id.linearLH);
			txtNotify = rootView.FindViewById<TextView>(Resource.Id.txtNotify_LT_HK);
		//	radioGroup = rootView.FindViewById<RadioGroup>(Resource.Id.radioGroup1);
		    bundle=this.Arguments;
			check = bundle.GetBoolean ("Remind");
			autoupdate = bundle.GetBoolean ("AutoUpdateData");

			//load data

			LoadData_HK ();
		
			// row click
			listView_HK.ItemLongClick += listView_ItemClick;
						

			return rootView;
		}
开发者ID:tienbui123,项目名称:Mobile-VS2,代码行数:30,代码来源:LichHocHKFragment.cs


示例4: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            if (!((GlobalvarsApp)this.Application).ISLOGON) {
                Finish ();
            }

            SetTitle (Resource.String.title_cash);

            // Create your application here
            SetContentView (Resource.Layout.ListView);
            pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
            COMPCODE = ((GlobalvarsApp)this.Application).COMPANY_CODE;
            rights = Utility.GetAccessRights (pathToDatabase);
            populate (listData);
            apara =  DataHelper.GetAdPara (pathToDatabase);
            listView = FindViewById<ListView> (Resource.Id.feedList);
            Button butNew= FindViewById<Button> (Resource.Id.butnewInv);
            butNew.Visibility = ViewStates.Gone;
            //butNew.Click += butCreateNewInv;
            Button butInvBack= FindViewById<Button> (Resource.Id.butInvBack);
            butInvBack.Click += (object sender, EventArgs e) => {
                StartActivity(typeof(POSSalesActivity));
            };

            //if (!rights.InvAllowAdd)
            //	butNew.Enabled = false;

            listView.ItemClick += OnListItemLongClick;//OnListItemClick;
            listView.ItemLongClick += ListView_ItemLongClick;
            //listView.Adapter = new CusotmListAdapter(this, listData);
            SetViewDlg viewdlg = SetViewDelegate;
            listView.Adapter = new GenericListAdapter<Invoice> (this, listData, Resource.Layout.ListItemRow, viewdlg);
        }
开发者ID:mokth,项目名称:merpV3,代码行数:34,代码来源:CashBillListing.cs


示例5: Issue1875

		public Issue1875()
		{
			Button loadData = new Button { Text = "Load", HorizontalOptions = LayoutOptions.FillAndExpand };
			ListView mainList = new ListView {
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.FillAndExpand
			};

			mainList.SetBinding (ListView.ItemsSourceProperty, "Items");

			_viewModel = new MainViewModel ();
			BindingContext = _viewModel;
			loadData.Clicked += async (sender, e) => {
				await LoadData ();
			};

			mainList.ItemAppearing += OnItemAppearing;

			Content = new StackLayout {
				Children = {
					loadData,
					mainList
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:25,代码来源:Issue1875.cs


示例6: WithoutDataTemplatePageCS

		public WithoutDataTemplatePageCS ()
		{
			Title = "Without a Data Template";
			Icon = "csharp.png";

			var people = new List<Person> {
				new Person ("Steve", 21, "USA"),
				new Person ("John", 37, "USA"),
				new Person ("Tom", 42, "UK"),
				new Person ("Lucas", 29, "Germany"),
				new Person ("Tariq", 39, "UK"),
				new Person ("Jane", 30, "USA")
			};

			var listView = new ListView { ItemsSource = people };

			Content = new StackLayout { 
				Padding = new Thickness (0, 20, 0, 0),
				Children = {
					new Label {
						Text = "ListView without a Data Template",
						FontAttributes = FontAttributes.Bold,
						HorizontalOptions = LayoutOptions.Center
					},
					listView
				}
			};
		}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:28,代码来源:WithoutDataTemplatePageCS.cs


示例7: LoadResourceXml

		public LoadResourceXml ()
		{
			#region How to load an XML file embedded resource
			var assembly = typeof(LoadResourceText).GetTypeInfo().Assembly;
			Stream stream = assembly.GetManifestResourceStream("WorkingWithFiles.PCLXmlResource.xml");

			List<Monkey> monkeys;
			using (var reader = new System.IO.StreamReader (stream)) {
				var serializer = new XmlSerializer(typeof(List<Monkey>));
				monkeys = (List<Monkey>)serializer.Deserialize(reader);
			}
			#endregion

			var listView = new ListView ();
			listView.ItemsSource = monkeys;


			Content = new StackLayout {
				Padding = new Thickness (0, 20, 0, 0),
				VerticalOptions = LayoutOptions.StartAndExpand,
				Children = {
					new Label { Text = "Embedded Resource XML File (PCL)", 
						FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
						FontAttributes = FontAttributes.Bold
					}, listView
				}
			};

			// NOTE: use for debugging, not in released app code!
			//foreach (var res in assembly.GetManifestResourceNames()) 
			//	System.Diagnostics.Debug.WriteLine("found resource: " + res);
		}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:32,代码来源:LoadResourceXml.cs


示例8: MenuPrincipalPage

        public MenuPrincipalPage()
        {
            List<MenuItem> data = new MenuListData();

            menus = new ListView();
            menus.ItemsSource = data;
            menus.VerticalOptions = LayoutOptions.FillAndExpand;
            menus.BackgroundColor = Color.Transparent;
            menus.SeparatorVisibility = SeparatorVisibility.None;
            menus.ItemTemplate = new DataTemplate(typeof(MenuViewCell));
            menus.ItemTapped += async (sender, e) => NavigateTo(e.Item as MenuItem);

            var mainLayout = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.Transparent,
                Orientation = StackOrientation.Vertical,
                Padding = new Thickness(10, 90, 10, 0),
                Children = { menus }
            };
            
            this.BackgroundColor = Colors._defaultColorFromHex;

            this.Content = mainLayout;
        }
开发者ID:jbravobr,项目名称:Mais-XamForms,代码行数:25,代码来源:MenuPrincipalPage.cs


示例9: OnListItemClick

        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            var person = ((PeopleGroupsAdapter)ListAdapter).GetPerson (position);

            if (person != null)
                StartActivity (PersonActivity.CreateIntent (this, person));
        }
开发者ID:tranuydu,项目名称:prebuilt-apps,代码行数:7,代码来源:SearchActivity.cs


示例10: OnListItemClick

        public override void OnListItemClick(ListView p0, View p1, int position, long p3)
        {
            Fragment newContent = null;
            switch (position)
            {
                case 0:
                    newContent = new ColorFragment(Resource.Color.red);
                    break;
                case 1:
                    newContent = new ColorFragment(Resource.Color.green);
                    break;
                case 2:
                    newContent = new ColorFragment(Resource.Color.blue);
                    break;
                case 3:
                    newContent = new ColorFragment(Resource.Color.white);
                    break;
                case 4:
                    newContent = new ColorFragment(Resource.Color.black);
                    break;
            }

            if (newContent != null)
                SwitchFragment(newContent);
        }
开发者ID:mamta-bisht,项目名称:SlidingMenuSharp,代码行数:25,代码来源:ColorMenuFragment.cs


示例11: OnCreate

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

			this.SetContentView(Resource.Layout.Main);

			var playButton = this.FindViewById<Button>(Resource.Id.PlayPauseButton);
			var stopButton = this.FindViewById<Button>(Resource.Id.StopButton);
			var searchView = this.FindViewById<SearchView>(Resource.Id.SearchView);
			this.listView = this.FindViewById<ListView>(Resource.Id.listView1);
			this.timeDisplay = this.FindViewById<TextView>(Resource.Id.TimeDisplay);
			this.adapter = new SongResultsAdapter(this, new Song[0]);
			this.player = new MediaPlayer();
			
			this.switcher = this.FindViewById<ViewSwitcher>(Resource.Id.ViewSwitcher);
			this.loadingMessage = this.FindViewById<TextView>(Resource.Id.LoadingMessage);
			
			playButton.Click += this.PlayButton_Click;
			stopButton.Click += this.StopButton_Click;
			searchView.QueryTextSubmit += this.SearchView_QueryTextSubmit;
			searchView.QueryTextChange += this.SearchView_QueryTextChange;
			this.listView.ItemClick += this.ListView_ItemClick;
			this.player.BufferingUpdate += this.Player_BufferingUpdate;
			this.player.Error += this.Player_Error;

			this.ShowListViewMessage("Write in the search box to start.");
		}
开发者ID:jairov4,项目名称:Ownfy,代码行数:27,代码来源:MainActivity.cs


示例12: IndividualListTest

        public IndividualListTest()
        {
            Title = "North Lakes";
            BackgroundColor = Color.White;

            listView = new ListView ();
            listView.ItemTemplate = new DataTemplate
                    (typeof (IndividualListCell));
            listView.ItemSelected += (sender, e) => {
                var itemSelected = (TapandGo.Data.ItemsListData)e.SelectedItem;
                //ListName = itemSelected.ListName;
               // ListName = TapandGo.Views.ShoppingListsTest.SelectedListName;
                var newPage = new TapandGo.Views.ListItemDetailPage();
                newPage.BindingContext = itemSelected;

                //((App)App.Current).ResumeAtTodoId = todoItem.ListName;
                //Debug.WriteLine("setting ResumeAtTodoId = " + todoItem.ID);
                Navigation.PushAsync(newPage);
                //((ListView)sender).SelectedItem = null;
            };

            var layout = new StackLayout();
            layout.Children.Add(listView);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            Content = layout;
        }
开发者ID:boxuanzhang,项目名称:woolies,代码行数:26,代码来源:IndividualListTest.cs


示例13: OnCreate

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

			// set our layout to be the home screen
			SetContentView(Resource.Layout.HomeScreen);

			//Find our controls
			taskListView = FindViewById<ListView> (Resource.Id.TaskList);
			addTaskButton = FindViewById<Button> (Resource.Id.AddButton);

			// wire up add task button handler
			if(addTaskButton != null) {
				addTaskButton.Click += (sender, e) => {
					StartActivity(typeof(TodoItemScreen));
				};
			}
			
			// wire up task click handler
			if(taskListView != null) {
				taskListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
					var taskDetails = new Intent (this, typeof (TodoItemScreen));
					taskDetails.PutExtra ("TaskID", tasks[e.Position].ID);
					StartActivity (taskDetails);
				};
			}
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:27,代码来源:HomeScreen.cs


示例14: ContactsPage

        public ContactsPage()
        {
            contactsList = new ListView();

            var cell = new DataTemplate(typeof(TextCell));

            cell.SetBinding(TextCell.TextProperty, "FirstName");
            cell.SetBinding(TextCell.DetailProperty, "LastName");

            contactsList.ItemTemplate = cell;

            contactsList.ItemSelected += (sender, args) =>
            {
                if (contactsList.SelectedItem == null)
                    return;

                var contact = contactsList.SelectedItem as Contact;

                Navigation.PushAsync(new ContactPage(contact));

                contactsList.SelectedItem = null;
            };

            Content = contactsList;
        }
开发者ID:Jazzeroki,项目名称:Xamarin.Plugins,代码行数:25,代码来源:ContactsPage.cs


示例15: ListView

		void IOptionsPanel.Initialize (OptionsDialog dialog, object dataObject)
		{
			this.ExpandHorizontal = true;
			this.ExpandVertical = true;
			this.HeightRequest = 400;
			list = new ListView ();
			store = new ListStore (language, completeOnSpace, completeOnChars);

			var languageColumn = list.Columns.Add (GettextCatalog.GetString ("Language"), language);
			languageColumn.CanResize = true;

			var checkBoxCellView = new CheckBoxCellView (completeOnSpace);
			checkBoxCellView.Editable = true;
			var completeOnSpaceColumn = list.Columns.Add (GettextCatalog.GetString ("Complete on space"), checkBoxCellView);
			completeOnSpaceColumn.CanResize = true;

			var textCellView = new TextCellView (completeOnChars);
			textCellView.Editable = true;
			var doNotCompleteOnColumn = list.Columns.Add (GettextCatalog.GetString ("Do complete on"), textCellView);
			doNotCompleteOnColumn.CanResize = true;
			list.DataSource = store;
			PackStart (list, true, true);

			var hbox = new HBox ();
			var button = new Button ("Reset to default");
			button.Clicked += delegate {
				FillStore (CompletionCharacters.GetDefaultCompletionCharacters ());
			};	
			hbox.PackEnd (button, false, false);
			PackEnd (hbox, false, true);
			FillStore (CompletionCharacters.GetCompletionCharacters ());
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:32,代码来源:CompletionCharactersPanel.cs


示例16: OnCreate

		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			mHandler = new Handler ();

			// Inflate our UI from its XML layout description.
			SetContentView (Resource.Layout.voice_recognition);

			// Get display items for later interaction
			Button speakButton = FindViewById <Button> (Resource.Id.btn_speak);

			mList = FindViewById <ListView> (Resource.Id.list);

			mSupportedLanguageView = FindViewById <Spinner> (Resource.Id.supported_languages);

			// Check to see if a recognition activity is present
			PackageManager pm = PackageManager;
			IList<ResolveInfo> activities = pm.QueryIntentActivities (new Intent (RecognizerIntent.ActionRecognizeSpeech), 0);

			if (activities.Count != 0)
				speakButton.Click += speakButton_Click;
			else {
				speakButton.Enabled = false;
				speakButton.Text = "Recognizer not present";
			}

			// Most of the applications do not have to handle the voice settings. If the application
			// does not require a recognition in a specific language (i.e., different from the system
			// locale), the application does not need to read the voice settings.
			RefreshVoiceSettings();
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:31,代码来源:VoiceRecognition.cs


示例17: MenuPage

		public MenuPage ()
		{
			Icon = "settings.png";
			Title = "Gráficos"; // The Title property must be set.
			BackgroundColor = Color.FromHex ("333333");

			Menu = new MenuListView ();

			var menuLabel = new ContentView {
				Padding = new Thickness (10, 36, 0, 5),
				Content = new Label {
					TextColor = Color.FromHex ("AAAAAA"),
					Text = "Gráficos", 
				}
			};

			var layout = new StackLayout { 
				Spacing = 0, 
				VerticalOptions = LayoutOptions.FillAndExpand
			};
			layout.Children.Add (menuLabel);
			layout.Children.Add (Menu);

			Content = layout;
		}
开发者ID:raynerhmc,项目名称:XamarinFormsPesquera,代码行数:25,代码来源:MenuPage.cs


示例18: OnCreate

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

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

            comicListView = FindViewById<ListView>(Resource.Id.ComicList);
            comicListView.ChoiceMode = ChoiceMode.Multiple;
            comicListView.FastScrollEnabled = true;

            data = new ComicList (new CSVParser (Assets.Open ("Data/titles.csv")));

            // wire up task click handler
            if(comicListView != null) {
                comicListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
                {
                    // Starting to think I should just serialize this
                    var comicDetails = new Intent (this, typeof (ComicDetailsActivity));
                    comicDetails.PutExtra("ComicName", data[e.Position].Name);
                    comicDetails.PutExtra("ComicDescription", data[e.Position].Description);
                    comicDetails.PutExtra("ComicPublisher", data[e.Position].Publisher);
                    comicDetails.PutExtra("ComicDate", data[e.Position].Date);
                    comicDetails.PutExtra("ID", data[e.Position].ID);
                    comicDetails.PutExtra("Favourite", data.IsFavourite(e.Position));
                    comicDetails.PutExtra("OtherComics", data.GetPublisherCount(data[e.Position].Publisher) - 1);
                    StartActivity (comicDetails);
                };
            }
        }
开发者ID:Aciho,项目名称:DevTest-Xamarin,代码行数:30,代码来源:MainActivity.cs


示例19: CreateMenuPage

		protected void CreateMenuPage(string menuPageTitle)
		{
			var _menuPage = new ContentPage ();
			_menuPage.Title = menuPageTitle;
			var listView = new ListView();

			listView.ItemsSource = new string[] { "Contacts", "Quotes", "Modal Demo" };

			listView.ItemSelected += async (sender, args) =>
			{

				switch ((string)args.SelectedItem) {
				case "Contacts":
					_tabbedNavigationPage.CurrentPage = _contactsPage;
					break;
				case "Quotes":
					_tabbedNavigationPage.CurrentPage = _quotesPage;
					break;
				case "Modal Demo":
                    var modalPage = FreshPageModelResolver.ResolvePageModel<ModalPageModel>();
					await PushPage(modalPage, null, true);
					break;
				default:
				break;
				}

				IsPresented = false;
			};

			_menuPage.Content = listView;

			Master = new NavigationPage(_menuPage) { Title = "Menu" };
		}
开发者ID:gaoxl,项目名称:FreshMvvm,代码行数:33,代码来源:CustomImplementedNav.cs


示例20: MyMasterDetail

        public MyMasterDetail()
        {
            Label header = new Label
            {
                Text = "MasterDetailPage",
                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center
            };
            string[] myList = new string[10];
            myList[0] = "Content Demo";
            //myList [1] = "Tabbed Demo";
            //myList[2] = "Carousel Demo";
            ListView listView = new ListView
            {
                ItemsSource = myList
            };
            this.Master = new ContentPage
            {
                Title = header.Text,
                Content = new StackLayout
                {
                    Children =
                    {
                        header,
                        listView

                    }
                    }
            };
            this.Detail = new NavigationPage(new HomePage());
        }
开发者ID:CTS458641,项目名称:cts458701,代码行数:31,代码来源:MyMasterDetail.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ListViewColumn类代码示例发布时间:2022-05-24
下一篇:
C# ListValue类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap