Esempio n. 1
0
		public override bool OnCreateOptionsMenu (Xamarin.ActionbarSherlockBinding.Views.IMenu menu)
		{
			//Used to put dark icons on light action bar
			bool isLight = SampleList.THEME == Resource.Style.Theme_Sherlock_Light;

			menu.Add ("Save")
				.SetIcon (isLight ? Resource.Drawable.ic_compose_inverse : Resource.Drawable.ic_compose)
					.SetShowAsAction (MenuItem.ShowAsActionIfRoom);

			menu.Add ("Search")
				.SetShowAsAction (MenuItem.ShowAsActionIfRoom | MenuItem.ShowAsActionWithText);

			menu.Add ("Refresh")
				.SetIcon (isLight ? Resource.Drawable.ic_refresh_inverse : Resource.Drawable.ic_refresh)
					.SetShowAsAction (MenuItem.ShowAsActionIfRoom | MenuItem.ShowAsActionWithText);

			return true;
		}
Esempio n. 2
0
		public override bool OnCreateOptionsMenu (Xamarin.ActionbarSherlockBinding.Views.IMenu menu)
		{
			for (int i = 0; i < items; i++) {
				menu.Add ("Text")
					.SetIcon (Resource.Drawable.ic_title_share_default)
						.SetShowAsAction (MenuItem.ShowAsActionIfRoom | MenuItem.ShowAsActionWithText);
			}

			return base.OnCreateOptionsMenu (menu);
		}
		public override bool OnCreateOptionsMenu (Xamarin.ActionbarSherlockBinding.Views.IMenu menu)
		{
			//Used to put dark icons on light action bar
			bool isLight = SampleList.THEME == Resource.Style.Theme_Sherlock_Light;

			menu.Add ("Search")
				.SetIcon (isLight ? Resource.Drawable.ic_search_inverse : Resource.Drawable.ic_search)
					.SetActionView (Resource.Layout.collapsible_edittext)
					.SetShowAsAction (MenuItem.ShowAsActionAlways | MenuItem.ShowAsActionCollapseActionView);

			return true;
		}
        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;
        }
        public override bool OnCreateOptionsMenu(Xamarin.ActionbarSherlockBinding.Views.IMenu menu)
        {
            if (ThisApp.ReaderKind != ReaderKind.WOLReader)
            {
                var previousMenu = menu.Add(0, PREVIOUS_MENU, PREVIOUS_MENU, "Previous");
                previousMenu.SetShowAsAction(1);
                previousMenu.SetIcon(Android.Resource.Drawable.IcMediaRew);

                var nextMenu = menu.Add(0, NEXT_MENU, NEXT_MENU, "Next");
                nextMenu.SetShowAsAction(1);
                nextMenu.SetIcon(Android.Resource.Drawable.IcMediaFf);
            }

            if (ThisApp.ReaderKind == ReaderKind.BibleReader)
            {
                var noteMenu = menu.Add(0, NOTE_MENU, NOTE_MENU, "Note");
                noteMenu.SetShowAsAction(1);
                noteMenu.SetIcon(Android.Resource.Drawable.IcMenuAdd);
            }

            if (ThisApp.ReaderKind == ReaderKind.DailyTextReader)
            {
                var todayMenu = menu.Add(0, TODAY_MENU, TODAY_MENU, "Today");
                todayMenu.SetShowAsAction(1);
                todayMenu.SetIcon(Android.Resource.Drawable.IcMenuToday);
            }

            if (ThisApp.ReaderKind == ReaderKind.PublicationReader)
            {
                //var highlightMenu = menu.Add(0, HIGHLIGHT_MENU, HIGHLIGHT_MENU, "Highlighter");
                //highlightMenu.SetShowAsAction(1);
            }

            if (ThisApp.ReaderKind == ReaderKind.WOLReader)
            {
                var saveMenu = menu.Add(0, SAVE_MENU, SAVE_MENU, "Save");
                saveMenu.SetShowAsAction(1);
                saveMenu.SetIcon(Android.Resource.Drawable.IcMenuSave);
            }

            var translateMenu = menu.Add(0, TRANSLATE_MENU, TRANSLATE_MENU, "Translate");
            translateMenu.SetShowAsAction(1);
            translateMenu.SetIcon(Android.Resource.Drawable.IcMenuRotate);

            var gotoMenu = menu.Add(0, GOTO_MENU, GOTO_MENU, "Look Up");
            gotoMenu.SetShowAsAction(1);
            gotoMenu.SetIcon(Android.Resource.Drawable.IcMenuUpload);

            return base.OnCreateOptionsMenu(menu);
        }