旗下导航:搜·么
当前位置:网站首页 > .Net教程 > 正文

C# 运用 Xamarin开辟运用--list+search【C#.Net教程】,C#,Xamarin,list+search

作者:搜教程发布时间:2019-11-27分类:.Net教程浏览:70评论:0


导读:C#运用Xamarin开辟运用--list+search[Activity(Label="ServiceBooking")]publicclassS...
C# 运用 Xamarin开辟运用--list+search

[Activity(Label = "ServiceBooking")]
    public class ServiceBooking : Activity
    {
        private SearchView _searchView;
        private ListView _lv;
        private ArrayAdapter<string> _adapter;
        private string[] _products;
        protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.ServiceBooking);
			// TODO :get from service
			_products = new []{"Dell Inspiron", "HTC One X", "HTC Wildfire S", "HTC Sense", "HTC Sensation XE",
				"iPhone 4S", "Samsung Galaxy Note 800",
				"Samsung Galaxy S3", "MacBook Air", "Mac Mini", "MacBook Pro"};

			_lv = FindViewById<ListView>(Resource.Id.listView1);
            _adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, _products);
			_lv.Adapter = _adapter;

            _searchView = FindViewById<SearchView>(Resource.Id.searchView1);
            _searchView.QueryTextChange += (sender, args) =>
            {
                _lv = FindViewById<ListView>(Resource.Id.listView1);
                _adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1,
                    _products.Where(p => p.ToLower()
                        .Contains(args.NewText.ToLower())).ToArray());
                _lv.Adapter = _adapter;
            };
		}

    }

以上就是C# 运用 Xamarin开辟运用--list+search的内容,更多相关内容请关注ki4网(www.ki4.cn)!

标签:C#Xamarinlist+search


欢迎 发表评论: