本文整理汇总了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;
}
示例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);
}
示例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);
}