public override Android.Views.View GetView(int position, Android.Views.View convertView, ViewGroup parent) { Android.Views.View view = convertView; // re-use an existing view, if one is available // otherwise create a new one // this is for the first item ..... the add button if (view == null && position == 0) { lInflater = (LayoutInflater)context.GetSystemService(Android.Content.Context.LayoutInflaterService); view = lInflater.Inflate(Resource.Layout.first_item, parent, false); } // this is for the rest of items else if (view == null && position != 0) { lInflater = (LayoutInflater)context.GetSystemService(Android.Content.Context.LayoutInflaterService); view = lInflater.Inflate(Resource.Layout.item_child, parent, false); } ChildInformation item = this[position]; CircleImageView imageButton = view.FindViewById <CircleImageView>(Resource.Id.childImage); TextView tv_childNmae = view.FindViewById <TextView>(Resource.Id.childName); Bitmap imageBitmap = item.url; imageButton.SetImageBitmap(imageBitmap); // imageButton.SetImageResource(item.url); tv_childNmae.Text = item.childName; imageButton.Focusable = false; imageButton.FocusableInTouchMode = false; imageButton.Clickable = true; imageButton.Click += (sender, args) => Console.WriteLine("ImageButton {0} clicked", position); if (position >= 1) { tv_childNmae.SetTextColor(Color.White); if (position % 2 == 0) { view.SetBackgroundResource(Resource.Color.list_item_color2); } else { view.SetBackgroundResource(Resource.Color.list_item_color1); } } return(view); }
public async Task SnackBar(string message, TypeSnack typesnack) { if (typesnack == TypeSnack.Error) { Activity activity = CrossCurrentActivity.Current.Activity; Android.Views.View activityRootView = activity.FindViewById(Android.Resource.Id.Content); Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong); snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF")); Android.Views.View snackbarview = snackBar.View; snackbarview.SetBackgroundResource(Resource.Drawable.snackerror); ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters; paramss.SetMargins(30, 0, 30, 40); snackbarview.SetBackground( MainActivity.CurrentActivity.ApplicationContext.GetDrawable(Resource.Drawable.snackerror)); snackBar.Show(); } else { Activity activity = CrossCurrentActivity.Current.Activity; Android.Views.View activityRootView = activity.FindViewById(Android.Resource.Id.Content); Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong); snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF")); Android.Views.View snackbarview = snackBar.View; snackbarview.SetBackgroundResource(Resource.Drawable.snackBackground); ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters; paramss.SetMargins(30, 0, 30, 40); snackbarview.SetBackground( MainActivity.CurrentActivity.ApplicationContext.GetDrawable(Resource.Drawable.snackBackground)); snackBar.Show(); } }
public async Task SnackBarSucces(string message, string title, TypeSnackBar typeSnackBar) { if (typeSnackBar == TypeSnackBar.Bottom) { Activity activity = CrossCurrentActivity.Current.Activity; Android.Views.View activityRootView = activity.FindViewById(Android.Resource.Id.Content); Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong); snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF")); Android.Views.View snackbarview = snackBar.View; snackbarview.SetBackgroundResource(Resource.Drawable.snackBackground); ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters; paramss.SetMargins(30, 0, 30, 40); snackbarview.LayoutParameters = paramss; snackbarview.SetBackground( MainActivity.Current.ApplicationContext.GetDrawable(Resource.Drawable.snackBackground)); snackBar.Show(); } else if (typeSnackBar == TypeSnackBar.Top) { CookieBar.Build(MainActivity.Current) .SetIcon(Resource.Drawable.ic_done) .SetTitle(title) .SetIconAnimation(Resource.Animator.iconspin) .SetBackgroundColor(Resource.Color.backgroundcoockiesuccess) .SetTitleColor(Resource.Color.cookiebartitle) .SetMessageColor(Resource.Color.cookiebartitle) .SetMessage(message) .SetEnableAutoDismiss(true) .SetSwipeToDismiss(true) .Show(); } }
protected void SetSelectedBackground(AView view, bool isContextTarget = false) { int attribute = isContextTarget ? global::Android.Resource.Attribute.ColorLongPressedHighlight : global::Android.Resource.Attribute.ColorActivatedHighlight; using (var value = new TypedValue()) { if (_context.Theme.ResolveAttribute(attribute, value, true)) { view.SetBackgroundResource(value.ResourceId); } else { view.SetBackgroundResource(global::Android.Resource.Color.HoloBlueDark); } } }
public virtual Com.Zhy.Adapter.Abslistview.ViewHolder SetBackgroundRes(int viewId , int backgroundRes) { Android.Views.View view = GetView <View>(viewId); view.SetBackgroundResource(backgroundRes); return(this); }
protected override View GetCellCore(Cell item, View convertView, ViewGroup parent, Context context) { cell = base.GetCellCore(item, convertView, parent, context); selected = false; cell.SetBackgroundResource(Resource.Drawable.ViewCellBackground); var listView = parent as DroidListView; if (listView != null) { listView.SetSelector(Resource.Drawable.ViewCellBackground); } //if ((item is CustomViewCell) && (item as CustomViewCell).CanMove) // AddGestures(item as ViewCell, cell, parent); return(cell); }
/* * This method was used to create the circle view with animation. * */ private View GetCircleView(FrameLayout.LayoutParams rParams, RandomData randomData) { var circleView = new View(this); circleView.SetBackgroundResource(Resource.Drawable.circle); circleView.Clickable = true; circleView.Focusable = true; circleView.FocusableInTouchMode = true; circleView.SetOnTouchListener(this); _rootLayout.AddView(circleView, rParams); circleView.StartAnimation(GetAnimationForNewViews()); if (randomData != null) { ChangeTitle(randomData.Title); } return(circleView); }
private void SetSelected() { if (!(Cell is RoundedViewCell formsCell)) { return; } int backgroundResource; if (formsCell.IsSelected) { backgroundResource = Resource.Drawable.ripple_rounded_viewcell_selected; } else { backgroundResource = Resource.Drawable.ripple_rounded_viewcell; } _nativeCell?.SetBackgroundResource(backgroundResource); }
void UpdateSeparatorColor(bool isHeader, AView bline) { if (bline == null) { return; } Color separatorColor = _listView.SeparatorColor; if (isHeader || !separatorColor.IsDefault) { bline.SetBackgroundColor(separatorColor.ToAndroid(Color.Accent)); } else { if (s_dividerHorizontalDarkId == int.MinValue) { using (var value = new TypedValue()) { int id = global::Android.Resource.Drawable.DividerHorizontalDark; if (_context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ListDivider, value, true)) { id = value.ResourceId; } else if (_context.Theme.ResolveAttribute(global::Android.Resource.Attribute.Divider, value, true)) { id = value.ResourceId; } s_dividerHorizontalDarkId = id; } } bline.SetBackgroundResource(s_dividerHorizontalDarkId); } }
void UpdateSeparatorColor(bool isHeader, AView bline) { if (bline == null) return; Color separatorColor = _listView.SeparatorColor; if (isHeader || !separatorColor.IsDefault) bline.SetBackgroundColor(separatorColor.ToAndroid(Color.Accent)); else { if (s_dividerHorizontalDarkId == int.MinValue) { using (var value = new TypedValue()) { int id = global::Android.Resource.Drawable.DividerHorizontalDark; if (_context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ListDivider, value, true)) id = value.ResourceId; else if (_context.Theme.ResolveAttribute(global::Android.Resource.Attribute.Divider, value, true)) id = value.ResourceId; s_dividerHorizontalDarkId = id; } } bline.SetBackgroundResource(s_dividerHorizontalDarkId); } }
private static AppMsg MakeText(Activity context, String text, Style style, View view, bool floating, float textSize, View.IOnClickListener clickListener) { AppMsg result = new AppMsg(context); view.SetBackgroundResource(style.Background); view.Clickable = true; TextView tv = view.FindViewById<TextView>(Android.Resource.Id.Message); if (textSize > 0) { tv.SetTextSize(Android.Util.ComplexUnitType.Sp, textSize); } tv.Text = text; result.mView = view; result.mDuration = style.Duration; result.mFloating = floating; view.SetOnClickListener(clickListener); return result; }
protected void UnsetSelectedBackground(AView view) { view.SetBackgroundResource(0); }
private void Refresh() { messageHandler.RemoveCallbacks(mCountdownRunnable); rootView.RemoveAllViews(); long currentTimeMillis = UIUtils.GetCurrentTime(Activity); // Show Loading... and load the view corresponding to the current state if (currentTimeMillis < UIUtils.CONFERENCE_START_MILLIS) { SetupBefore(); } else if (currentTimeMillis > UIUtils.CONFERENCE_END_MILLIS) { SetupAfter(); } else { SetupDuring(); } if (!UIUtils.IsHoneycombTablet(Activity)) { var separator = new View(Activity); separator.LayoutParameters = new ViewGroup.LayoutParams(1, ViewGroup.LayoutParams.FillParent); separator.SetBackgroundResource(Resource.Drawable.whats_on_separator); rootView.AddView(separator); View view = Activity.LayoutInflater.Inflate(Resource.Layout.whats_on_stream, rootView, false); view.Click += (sender, e) => { //AnalyticsUtils.getInstance(getActivity()).trackEvent("Home Screen Dashboard", "Click", "Realtime Stream", 0); var intent = new Intent(Activity, typeof(TagStreamActivity)); StartActivity(intent); }; rootView.AddView(view); } }
public virtual void changeLayout (View view) { mVideoLayout++; if (mVideoLayout == 4) { mVideoLayout = 0; } switch (mVideoLayout) { case 0: mVideoLayout = VideoView.VideoLayoutOrigin; view.SetBackgroundResource (Resource.Drawable.mediacontroller_sreen_size_100); break; case 1: mVideoLayout = VideoView.VideoLayoutScale; view.SetBackgroundResource (Resource.Drawable.mediacontroller_screen_fit); break; case 2: mVideoLayout = VideoView.VideoLayoutStretch; view.SetBackgroundResource (Resource.Drawable.mediacontroller_screen_size); break; case 3: mVideoLayout = VideoView.VideoLayoutZoom; view.SetBackgroundResource (Resource.Drawable.mediacontroller_sreen_size_crop); break; } mVideoView.SetVideoLayout (mVideoLayout, 0); }
private static AppMsg MakeText(Activity context, string text, Style style, View view, bool floating) { var result = new AppMsg(context); view.SetBackgroundResource(style.Background); var tv = (TextView)view.FindViewById(Android.Resource.Id.Message); tv.Text = text; result.View = view; result.Duration = style.Duration; result.SetFloating(floating); return result; }
public void ConfigureButtonContent(View view, ExpandableItem expandableItem) { if (expandableItem.HasBackgroundId()) { int backgroundId = expandableItem.BackgroundId; view.SetBackgroundResource(backgroundId); } if (expandableItem.HasTitle()) { var button = view as Button; if (button==null) { return; } string text = expandableItem.Title; button.Text = text; } if (expandableItem.HasResourceId()) { var imageButton = view as ImageButton; if (imageButton== null) { return; } int resourceId = expandableItem.ResourceId; imageButton.SetImageResource(resourceId); } }
public LinearLayout Build() { if(nn_itemlist.Count>0){ int number = nn_itemlist.Count; totalwidth = (int)(cellwidth+nn_containterpadding*2); totalheight = (int)(number*cellheight+(number-1)*nn_containerspacing+nn_containterpadding*2); for (int i = 0; i < nn_itemlist.Count; i++) { if (i > 0) { //LinearLayout.LayoutParams para = (LinearLayout.LayoutParams)nn_itemlist [i].LayoutParameters; //para.TopMargin = TapUtil.dptodx (nn_containerspacing); //add divier; View divider =new View(nn_context); divider.LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, TapUtil.dptodx (nn_containerspacing)); divider.SetBackgroundResource (Resource.Color.soarnix_bg_gray); nn_menucontainer.AddView (divider); } nn_menucontainer.AddView (nn_itemlist [i]); } return nn_menucontainer; }else{ Console.WriteLine ("failed add customize menu"); return null; } }
public override Android.Views.View GetView(int position, Android.Views.View view, ViewGroup parent) { var context = BlazorWebViewService.GetCurrentActivity(); int itemType = GetItemViewType(position); int layoutId; if (itemType == TYPE_SEPARATOR) { if (mSeparator == null) { mSeparator = new Android.Views.View(context); mSeparator.LayoutParameters = new Android.Widget.ListView.LayoutParams(ViewGroup.LayoutParams.MatchParent, 2, itemType); TypedArray attr = context.ObtainStyledAttributes( new int[] { Android.Resource.Attribute.ListDivider }); mSeparator.SetBackgroundResource(attr.GetResourceId(0, 0)); attr.Recycle(); } return(mSeparator); } else if (itemType == TYPE_MENU_ITEM) { layoutId = Android.Resource.Layout.SimpleListItem1; } else if (itemType == TYPE_MENU_CHECK) { layoutId = Android.Resource.Layout.SimpleListItemChecked; } else if (itemType == TYPE_GROUP) { layoutId = Android.Resource.Layout.PreferenceCategory; } else if (itemType == TYPE_SINGLE) { layoutId = Android.Resource.Layout.SimpleListItemSingleChoice; } else if (itemType == TYPE_MULTIPLE) { layoutId = Android.Resource.Layout.SimpleListItemMultipleChoice; } else { throw new UnsupportedOperationException(); } if (view == null) { if (mInflater == null) { mInflater = LayoutInflater.From(_builder.Context); } view = mInflater.Inflate(layoutId, parent, false); } ModifiableChoice item = GetItem(position); TextView text = (TextView)view; text.Enabled = !item.Choice.Disabled; text.Text = item.ModifiableLabel; if (view is CheckedTextView) { bool selected = item.ModifiableSelected; if (itemType == TYPE_MULTIPLE) { _list.SetItemChecked(position, selected); } else { ((CheckedTextView)view).Checked = selected; } } return(view); }