/// <summary> /// Recursively go through the parents of the view trying to find one that specifies /// a data source. /// </summary> /// <returns>The parent data source, <c>null</c> if no source found.</returns> private object FindParentDataSource(IViewParent viewParent) { var view = viewParent as View; if (view == null) return null; var tag = view.GetBindingTag (); if (tag != null) { if (tag.OverrideDataSource) { return tag.DataSource; } } return FindParentDataSource (view.Parent); }
// public ActionBarViewWrapper(IViewParent actionBarView) public ActionBarViewWrapper(View actionBarView) { if (!actionBarView.Class.Name.Contains("ActionBarView")) { String previousP = actionBarView.Class.Name; actionBarView = (View)actionBarView.Parent; String throwP = actionBarView.Class.Name; if (!actionBarView.Class.Name.Contains("ActionBarView")) { throw new Java.Lang.IllegalStateException("Cannot find ActionBarView for " + "Activity, instead found " + previousP + " and " + throwP); } } mActionBarView = (IViewParent)actionBarView; mActionBarViewClass = actionBarView.Class; mAbsActionBarViewClass = actionBarView.Class.Superclass; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Console.WriteLine("Locale: " + Resources.Configuration.Locale); // eg. es_ES Console.WriteLine("Locale: " + Resources.Configuration.Locale.DisplayName); // eg. español (España) View titleView = Window.FindViewById(Android.Resource.Id.Title); if (titleView != null) { IViewParent parent = titleView.Parent; if (parent != null && (parent is View)) { View parentView = (View)parent; parentView.SetBackgroundColor(Color.Rgb(0x26, 0x75, 0xFF)); //38, 117 ,255 } } int taskID = Intent.GetIntExtra("TaskID", 0); if (taskID > 0) { task = null; //HACK:Tasky.BL.Managers.TaskManager.GetTask(taskID); } // set our layout to be the home screen SetContentView(Resource.Layout.TaskDetails); nameTextEdit = FindViewById <EditText>(Resource.Id.txtName); notesTextEdit = FindViewById <EditText>(Resource.Id.txtNotes); saveButton = FindViewById <Button>(Resource.Id.btnSave); doneCheckbox = FindViewById <CheckBox>(Resource.Id.chkDone); // find all our controls cancelDeleteButton = FindViewById <Button>(Resource.Id.btnCancelDelete); // get translations var cancelString = Resources.GetText(Resource.String.taskcancel); //getResources().getText(R.string.main_title) var deleteString = Resources.GetText(Resource.String.taskdelete); // set the cancel delete based on whether or not it's an existing task if (cancelDeleteButton != null) { cancelDeleteButton.Text = (task.ID == 0 ? cancelString : deleteString); } // name if (nameTextEdit != null) { nameTextEdit.Text = task.Name; } // notes if (notesTextEdit != null) { notesTextEdit.Text = task.Notes; } if (doneCheckbox != null) { doneCheckbox.Checked = task.Done; } // button clicks cancelDeleteButton.Click += (sender, e) => { CancelDelete(); }; saveButton.Click += (sender, e) => { Save(); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); View titleView = Window.FindViewById(Android.Resource.Id.Title); if (titleView != null) { IViewParent parent = titleView.Parent; if (parent != null && (parent is View)) { View parentView = (View)parent; parentView.SetBackgroundColor(Color.Rgb(0x26, 0x75, 0xFF)); //38, 117 ,255 } } int taskID = Intent.GetIntExtra("TaskID", 0); if (taskID > 0) { task = Tasky.BL.Managers.TaskManager.GetTask(taskID); } // set our layout to be the home screen SetContentView(Resource.Layout.TaskDetails); nameTextEdit = FindViewById <EditText>(Resource.Id.txtName); notesTextEdit = FindViewById <EditText>(Resource.Id.txtNotes); saveButton = FindViewById <Button>(Resource.Id.btnSave); doneCheckbox = FindViewById <CheckBox>(Resource.Id.chkDone); // find all our controls cancelDeleteButton = FindViewById <Button>(Resource.Id.btnCancelDelete); // set the cancel delete based on whether or not it's an existing task if (cancelDeleteButton != null) { cancelDeleteButton.Text = (task.ID == 0 ? "Cancel" : "Delete"); } // name if (nameTextEdit != null) { nameTextEdit.Text = task.Name; } // notes if (notesTextEdit != null) { notesTextEdit.Text = task.Notes; } if (doneCheckbox != null) { doneCheckbox.Checked = task.Done; } // button clicks cancelDeleteButton.Click += (sender, e) => { CancelDelete(); }; saveButton.Click += (sender, e) => { Save(); }; }
public bool OnTouchEvent(MotionEvent e, IViewParent parent, out bool handled) { return(_gestureManager.OnTouchEvent(e, parent, out handled)); }
void Initialize(IAttributeSet attrs, int defStyle) { mTouchListener = new OnTouchListener(this); mOnHieratchyChangeListener = new OnHierarchyChangeListener() { OnChildViewAddedAction = (View parent, View child) => { Log.Debug(TAG, "Child is added: " + child); IViewParent scrollView = parent.Parent; if (scrollView != null && scrollView is ScrollView) { ((ScrollView)scrollView).FullScroll(FocusSearchDirection.Down); } if (this.LayoutTransition != null) { View view = child.FindViewById(Resource.Id.card_actionarea); if (view != null) { view.Alpha = 0; } } }, OnChildViewRemovedAction = (View parent, View child) => { Log.Debug(TAG, "Child is removed: " + child); mFixedViewList.Remove(child); } }; mTransitionListener = new TransitionListener() { StartTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) => { Log.Debug(TAG, "Start LayoutTransition animation: " + transitionType); }, EndTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) => { Log.Debug(TAG, "End LayoutTransition animation: " + transitionType); if (transitionType == LayoutTransitionType.Appearing) { View area = view.FindViewById(Resource.Id.card_actionarea); if (area != null) { RunShowActionAreaAnimation(container, area); } } } }; float speedFactor = 1f; if (attrs != null) { var v = Resource.Styleable.CardStream; TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.CardStream, defStyle, 0); if (a != null) { int speedType = a.GetInt(Resource.Styleable.CardStream_animationDuration, 1001); switch (speedType) { case ANIMATION_SPEED_FAST: speedFactor = 0.5f; break; case ANIMATION_SPEED_NORMAL: speedFactor = 1f; break; case ANIMATION_SPEED_SLOW: speedFactor = 2f; break; } string animatorName = a.GetString(Resource.Styleable.CardStream_animators); try { if (animatorName != null) { mAnimators = Class.ClassLoader.LoadClass(animatorName).NewInstance() as CardStreamAnimator; } } catch (Exception e) { Log.Error(TAG, "Failed to load animator: " + animatorName, e); } finally { if (mAnimators == null) { mAnimators = new DefaultCardStreamAnimator(); } } a.Recycle(); } } mAnimators.SpeedFactor = speedFactor; mSwipeSlop = ViewConfiguration.Get(Context).ScaledTouchSlop; SetOnHierarchyChangeListener(mOnHieratchyChangeListener); }
/// <summary> /// Return First parent of the view of specified T type. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="view"></param> /// <returns>First parent of the view of specified T type.</returns> public static T FindFirstParent <T>(this IViewParent view) where T : class => FindFirstParentOfView <T>(view as View);
public static T FindFirstParent <T>(this IViewParent view, bool includeCurrent) where T : class => FindFirstParentOfView <T>(view as View, includeCurrent);
/// <summary> /// Return First parent of the view of specified T type. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="view"></param> /// <returns>First parent of the view of specified T type.</returns> public static T FindFirstParent <T>(this IViewParent view) where T : class => FindFirstParent <T>(view, includeCurrent : false);
protected override void UpdateDetailDisplay(View cell) { if (cell == null) { return; } TextView label; EditText _entry; DroidResources.DecodeStringEntryLayout(Context, cell, out label, out _entry); if (_entry == null) { return; } if (_entry.Text != Value) { _entry.Text = Value; } if (_entry.Hint != Hint) { _entry.Hint = Hint; } var inputType = KeyboardType.InputTypesFromUIKeyboardType(); if (Password) { inputType |= InputTypes.TextVariationPassword; } if (IsEmail) { inputType |= AndroidDialogEnumHelper.KeyboardTypeMap[UIKeyboardType.EmailAddress]; } if (Numeric) { inputType |= AndroidDialogEnumHelper.KeyboardTypeMap[UIKeyboardType.DecimalPad]; } if (NoAutoCorrect) { inputType |= AndroidDialogEnumHelper.KeyboardTypeMap[UIKeyboardType.NoAutoCorrect]; } if (Lines > 1) { inputType |= InputTypes.TextFlagMultiLine; if (_entry.LineCount != Lines) { _entry.SetLines(Lines); } } else if (Send != null) { if (_entry.ImeOptions != ImeAction.Go) { _entry.ImeOptions = ImeAction.Go; _entry.SetImeActionLabel("Go", ImeAction.Go); } } else { var imeOptions = ReturnKeyType.ImeActionFromUIReturnKeyType(); if (_entry.ImeOptions != imeOptions) { _entry.ImeOptions = imeOptions; } } if (_entry.InputType != inputType) { _entry.InputType = inputType; } //android can't seem to find the correct NextFocusDown if items are added dynamically, we'll catch the next/previous ourselves _entry.EditorAction += (sender, args) => { if (args.ActionId == ImeAction.Next || (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Honeycomb && args.ActionId == ImeAction.Previous)) { ViewGroup group = _entry.Parent as ViewGroup; IViewParent currentLoop = _entry.Parent; while (currentLoop != null) { currentLoop = currentLoop.Parent; if (currentLoop is ViewGroup) { group = (ViewGroup)currentLoop; } } var focus = FocusFinder.Instance.FindNextFocus(group, _entry, args.ActionId == ImeAction.Next ? FocusSearchDirection.Down : FocusSearchDirection.Up); if (focus != null) { focus.RequestFocus(); focus.RequestFocusFromTouch(); } } }; }