C# 使用 Xamarin开发应用--list+search
程序员文章站
2022-03-25 22:43:46
...
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的内容,更多相关内容请关注PHP中文网(www.php.cn)!
上一篇: 在Vue中如何实现服务器渲染Nuxt
下一篇: 微信小程序首页数据初始化失败的解决方法