Пример #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.CatalogsFragment, container, false);

            catalogs = new CheckinShared.CatalogDB ();

            Activity.SetProgressBarIndeterminateVisibility (false);
            Activity.SetProgressBarVisibility (false);

            ProgressBar progressbarSearch = rootView.FindViewById<ProgressBar> (Resource.Id.CatalogListprogressBar);
            progressbarSearch.Visibility = ViewStates.Gone;

            listViewCatalogs = rootView.FindViewById<ListView> (Resource.Id.CatalogListView);
            adapter = new CatalogAdapter (Activity);

            SearchView searchViewCatalog = rootView.FindViewById<SearchView> (Resource.Id.CatalogListsearchView1);

            listViewCatalogs.Adapter = adapter;

            Toast.MakeText(Activity, catalogs.Count() + " catálogos creados", ToastLength.Long).Show();

            listViewCatalogs.ItemLongClick += delegate(object sender, AdapterView.ItemLongClickEventArgs e) {
                DeleteCatalogDialogFragment dialog = new DeleteCatalogDialogFragment();
                dialog.Catalog = adapter.GetCatalog(e.Position);
                dialog.Show(FragmentManager, "DeleteCatalogDialogFragment");
            };

            listViewCatalogs.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e) {
                Intent intent = new Intent (Activity, typeof(CatalogActivity));
                intent.PutExtra("Name",adapter.GetCatalog(e.Position).Name);
                intent.PutExtra("Id",adapter.GetCatalog(e.Position).Id);
                // StartActivityForResult (intent, 18);
                StartActivity(intent);
            };

            searchViewCatalog.QueryTextSubmit += delegate(object sender, SearchView.QueryTextSubmitEventArgs e) {
                Console.WriteLine(searchViewCatalog.Query);
                progressbarSearch.Visibility = ViewStates.Visible;
                adapter.Clear();
                foreach (Catalog catalog in catalogs.All()) {
                    if(searchViewCatalog.Query.IndexOf(catalog.Name) != -1)
                    {
                        adapter.Add(catalog);
                    }
                }
                progressbarSearch.Visibility = ViewStates.Gone;
            };

            searchViewCatalog.Close += delegate(object sender, SearchView.CloseEventArgs e) {
                progressbarSearch.Visibility = ViewStates.Gone;
            };

            RefreshList ();

            return rootView;
        }