private NicknamesAdapter GetNicknamesList(string userdata) { string UserData = userdata; UserDataObject = JsonConvert.DeserializeObject <JsonClass.RootObject>(UserData); var List = new List <Nickname>(); for (int i = 0; i < UserDataObject.Nicknames.Count; i++) { int result = NicknamesListContains(List, UserDataObject.Nicknames[i]); if (result != -1) { List[result].Count++; } else { List.Add(new Nickname { Name = UserDataObject.Nicknames[i].m_Item1, Count = 1 }); } } List <Nickname> SortedList = new List <Nickname>(); List.Sort((a, b) => a.Count); MainActivity.NicknamesList = List; NicknamesAdapter adapter = new NicknamesAdapter((Activity)context, MainActivity.NicknamesList); return(adapter); }
public override Java.Lang.Object InstantiateItem(ViewGroup container, int position) { context = container.Context; view = LayoutInflater.From(container.Context).Inflate(Resource.Layout.pager_item, container, false); container.AddView(view); lview = view.FindViewById <ListView>(Resource.Id.listview); var sview = view.FindViewById <SearchView>(Resource.Id.searchview); var cnumber = view.FindViewById <TextView>(Resource.Id.tvCurrentNumber); var swiperefreshview = view.FindViewById <Android.Support.V4.Widget.SwipeRefreshLayout>(Resource.Id.swiperefresh); var rlAbout = view.FindViewById <RelativeLayout>(Resource.Id.rlFragAbout); view.FindViewById <ListView>(Resource.Id.lvSearchResults).Visibility = ViewStates.Gone; if (FirstOpen) { swiperefreshview.Refresh += Swiperefreshview_Refresh; swiperefreshview.Refreshing = true; Swiperefreshview_Refresh(swiperefreshview, null); FirstOpen = false; } sview.SetQueryHint("Search A Specific Phone Number"); NicknamesAdapter adapter = GetNicknamesList(intent.GetStringExtra("userdata")); lview.Adapter = adapter; lview.ItemClick += Lview_ItemClick; string PhoneNumber = intent.GetStringExtra("PhoneNumber"); if (PhoneNumber.Length == 9) { cnumber.Text = "Names For : " + PhoneNumber.Substring(0, 2) + " - " + PhoneNumber.Substring(2); } else if (PhoneNumber.Length == 10) { cnumber.Text = "Names For : " + PhoneNumber.Substring(0, 3) + " - " + PhoneNumber.Substring(3); } else { cnumber.Text = "Names For : " + PhoneNumber; } sview.QueryTextSubmit += Sview_QueryTextSubmit; sview.SetInputType(Android.Text.InputTypes.ClassPhone); switch (position) { case 0: ShowKeyboard(); lview.Visibility = ViewStates.Visible; swiperefreshview.Visibility = ViewStates.Visible; cnumber.Visibility = ViewStates.Visible; rlAbout.Visibility = ViewStates.Invisible; sview.Visibility = ViewStates.Invisible; break; case 1: lview.Visibility = ViewStates.Gone; rlAbout.Visibility = ViewStates.Invisible; swiperefreshview.Visibility = ViewStates.Gone; cnumber.Visibility = ViewStates.Gone; sview.Visibility = ViewStates.Visible; sview.Focusable = true; sview.FocusableInTouchMode = true; if (count++ == 0) { HideKeyboard(); } else { sview.RequestFocus(); } break; case 2: ShowKeyboard(); rlAbout.Visibility = ViewStates.Visible; cnumber.Visibility = ViewStates.Gone; swiperefreshview.Visibility = ViewStates.Gone; sview.Visibility = ViewStates.Gone; break; } return(view); }