当前位置: 首页>>代码示例>>C#>>正文


C# Xamarin.FindItem方法代码示例

本文整理汇总了C#中Xamarin.FindItem方法的典型用法代码示例。如果您正苦于以下问题:C# Xamarin.FindItem方法的具体用法?C# Xamarin.FindItem怎么用?C# Xamarin.FindItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xamarin的用法示例。


在下文中一共展示了Xamarin.FindItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreateOptionsMenu

        public override bool OnCreateOptionsMenu(Xamarin.ActionbarSherlockBinding.Views.IMenu menu)
        {
            // Skapar en sökvy
            var searchView = new SearchView(SupportActionBar.ThemedContext)
            {
                QueryHint = "Search artist..."
            };
            searchView.SetOnQueryTextListener(this);

            menu.Add(1, 1, 1, "Search")
                .SetActionView(searchView)
                .SetIcon(Android.Resource.Drawable.abs__ic_search)
                .SetShowAsAction(MenuItem.ShowAsActionAlways | MenuItem.ShowAsActionCollapseActionView);
            var searchItemActionBar = menu.FindItem(1);

            searchView.QueryTextSubmit += async (sender, e) =>
            {
                searchItemActionBar.CollapseActionView();
                SetSupportProgressBarIndeterminateVisibility(true);
                searchView.ClearFocus();
                try
                {
                    var artistName = await _repository.FindArtistAsync(e.Query);
                    var artist = await _repository.SearchArtistAsync(artistName);
                    var topTracks = await _repository.GetTopTracksAsync(artist.Name);
                    var topAlbums = await _repository.GetTopAlbumsAsync(artist.Name);

                    // Serialisera objektet och skicka det till artistactivity...
                    var jsonArtist = JsonConvert.SerializeObject(artist);
                    var jsonTopTracks = JsonConvert.SerializeObject(topTracks.Take(15));
                    var jsonTopAlbums = JsonConvert.SerializeObject(topAlbums.Take(5));

                    var artistActivity = new Intent(this, typeof(ArtistActivity));

                    artistActivity.PutExtra("Artist", jsonArtist);
                    artistActivity.PutExtra("TopTracks", jsonTopTracks);
                    artistActivity.PutExtra("TopAlbums", jsonTopAlbums);

                    SetSupportProgressBarIndeterminateVisibility(false);
                    StartActivity(artistActivity);
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "Error: " + ex.Message, ToastLength.Short).Show();
                    SetSupportProgressBarIndeterminateVisibility(false);
                }
            };
            return true;
        }
开发者ID:jonteho,项目名称:last.fm-appcrossplat,代码行数:49,代码来源:StartFragmentActivity.cs

示例2: OnCreateOptionsMenu

        public override bool OnCreateOptionsMenu(Xamarin.ActionbarSherlockBinding.Views.IMenu menu)
        {
            base.SupportMenuInflater.Inflate(Resource.Menu.main_menu, menu);

             // set up a listener for the refresh item
            Xamarin.ActionbarSherlockBinding.Views.IMenuItem refresh = (Xamarin.ActionbarSherlockBinding.Views.IMenuItem)menu.FindItem(Resource.Id.menu_refresh);

            // TODO:
            refresh.SetOnMenuItemClickListener(new MyMenuItemOnMenuItemClickListener());

            //        refresh.SetOnMenuItemClickListener(new OnMenuItemClickListener() {
            //    // on selecting show progress spinner for 1s
            //    public boolean onMenuItemClick(MenuItem item) {
            //        // item.setActionView(R.layout.progress_action);
            //        handler.postDelayed(new Runnable() {
            //            public void run() {
            //                refresh.setActionView(null);
            //            }
            //        }, 1000);
            //        return false;
            //    }
            //});
            return base.OnCreateOptionsMenu(menu);
        }
开发者ID:kbalint,项目名称:SherlockTest,代码行数:24,代码来源:Activity1.cs

示例3: OnCreateOptionsMenu

        public override void OnCreateOptionsMenu(Xamarin.ActionbarSherlockBinding.Views.IMenu menu, Xamarin.ActionbarSherlockBinding.Views.MenuInflater inflater)
        {
            inflater.Inflate(Resource.Menu.search_options_menu, menu);

            var search = (SearchView)menu.FindItem(Resource.Id.search).ActionView;

            search.SetQueryHint("Search Favorites");
            search.SetIconifiedByDefault(true);
            search.QueryTextChange += (sender, e) =>
            {
                if (notesAdapter != null)
                {
                    Console.WriteLine(search.Query);
                    notesAdapter.Filter.InvokeFilter(search.Query);
                    ListAdapter = notesAdapter;
                }
            };

            base.OnCreateOptionsMenu(menu, inflater);
        }
开发者ID:PablusVinii,项目名称:SuperNWTBible,代码行数:20,代码来源:FavoritesFragment.cs


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