public void SetListableObjects(IEnumerable <ListableObject> objects) { this.objects = objects.ToList(); if (objects.Count() > 0) { selection = this.objects[0]; String strName = this.objects[0].GetListText(); Text = strName; } else { selection = null; Text = ""; } }
private void ShowDialog() { if (dialogIsShow) { return; } dialogIsShow = true; /*AlertDialog.Builder builderSingle = new AlertDialog.Builder(Context); * String title = null; * builderSingle.SetTitle(title); * * ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(Context, Resource.Layout.item_dialog); * if (objects == null) * return; * for (int i = 0; i < objects.Count(); i++) * arrayAdapter.Add(objects.ElementAt(i)); * * builderSingle.SetNegativeButton("Cancelar", (s, ev) => * { * ((AlertDialog)s).Cancel(); * }); * * builderSingle.SetAdapter(arrayAdapter, (o, e) => * { * String strName = arrayAdapter.GetItem(e.Which); * Text = strName; * selection = e.Which; * ItemChanged?.Invoke(this, e.Which); * }); * builderSingle.Show();*/ var activity = Locator.Current.GetService <Activity>() as AppCompatActivity; var fragment = ListEditTextDialogFragment.NewInstance(); fragment.OnSelected += (o, item) => { Text = item.GetListText(); var oldSelection = selection; selection = item; if (!selection.GetListText().Equals(oldSelection.GetListText())) { ItemChanged?.Invoke(this, item); } }; fragment.Show(activity.SupportFragmentManager, "listedittext"); fragment.SetObjects(objects); fragment.OnDismissEvent += (o, e) => dialogIsShow = false; }
public void SetSelectionIndex(int selection) { if (objects != null && selection >= 0 && objects.Count > 0) { this.selection = objects.ElementAt(selection); String strName = objects.ElementAt(selection).GetListText(); if (Looper.MyLooper() == Looper.MainLooper) { Text = strName; } else { Post(() => Text = strName); } } else { } }
void SelectedAction(ListableObject selectedItem) { OnSelected?.Invoke(this, selectedItem); DismissView(); }