public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.emojicons, container, false); var emojisPager = view.FindViewById <ViewPager>(Resource.Id.emojis_pager); emojisPager.PageSelected += OnPageSelected; AddRecentEmoji += OnAddRecentEmoji; var emojiFragments = new List <EmojiconGridFragment> { EmojiconRecentsGridFragment.NewInstance(), EmojiconGridFragment.NewInstance(People.Data, this), EmojiconGridFragment.NewInstance(Nature.Data, this), EmojiconGridFragment.NewInstance(Objects.Data, this), EmojiconGridFragment.NewInstance(Places.Data, this), EmojiconGridFragment.NewInstance(Symbols.Data, this) }; foreach (var fragment in emojiFragments) { fragment.EmojiClicked += e => EmojiClicked?.Invoke(e); } _emojisAdapter = new EmojisPagerAdapter(FragmentManager, emojiFragments); emojisPager.Adapter = _emojisAdapter; //ToDo: Solve Recents Issue const int EMOJI_TABS_COUNT = 6; _emojiTabs = new View[EMOJI_TABS_COUNT]; _emojiTabs[0] = view.FindViewById(Resource.Id.emojis_tab_0_recents); _emojiTabs[1] = view.FindViewById(Resource.Id.emojis_tab_1_people); _emojiTabs[2] = view.FindViewById(Resource.Id.emojis_tab_2_nature); _emojiTabs[3] = view.FindViewById(Resource.Id.emojis_tab_3_objects); _emojiTabs[4] = view.FindViewById(Resource.Id.emojis_tab_4_cars); _emojiTabs[5] = view.FindViewById(Resource.Id.emojis_tab_5_punctuation); for (var i = 0; i < _emojiTabs.Length; i++) { var position = i; _emojiTabs[i].Click += (sender, e) => emojisPager.CurrentItem = position; } view.FindViewById(Resource.Id.emojis_backspace).Click += (sender, e) => { EmojiconBackspaceClicked?.Invoke((View)sender); }; // get last selected page EmojiconRecentsManager.Context = view.Context; var page = EmojiconRecentsManager.RecentPage; // last page was recents, check if there are recents to use // if none was found, go to page 1 if (page == 0 && EmojiconRecentsManager.Count == 0) { page = 1; } if (page == 0) { OnPageSelected(null, new ViewPager.PageSelectedEventArgs(page)); } else { emojisPager.SetCurrentItem(page, false); } return(view); }
public void OnItemClick(object sender, AdapterView.ItemClickEventArgs e) { EmojiClicked?.Invoke((Emojicon)e.Parent.GetItemAtPosition(e.Position)); }