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)!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号