public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
        {
            var item = GetChild(groupPosition, childPosition).ToString();

            if (convertView == null)
            {
                var inflater = LayoutInflater.FromContext(context);
                convertView = inflater.Inflate(Resource.Layout.expandablelistview_child, null);
            }

            var childText = (TextView)convertView.FindViewById(Resource.Id.elvTextChild);

            childText.SetText(item, TextView.BufferType.Normal);

            return(convertView);
        }
Exemple #2
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var item = _items[position];
            var view = convertView;

            if (view == null)
            {
                var inflater = LayoutInflater.FromContext(_context);
                view = inflater.Inflate(Resource.Layout.row, parent, false);
            }

            view.FindViewById <TextView>(Resource.Id.Weigh).Text = item.myWeight;
            view.FindViewById <TextView>(Resource.Id.Date).Text  = item.dateOfWeigh;

            return(view);
        }
Exemple #3
0
        private View CreateMoveUpButton()
        {
            View moveUpButton;

            if (iMoveUpButtonResourceId == 0)
            {
                moveUpButton = new Button(Context);
                (moveUpButton as Button).Text = "Up";
            }
            else
            {
                moveUpButton = LayoutInflater.FromContext(Context).Inflate(iMoveUpButtonResourceId, null);
            }
            moveUpButton.Id = kMoveUpButtonId;
            return(moveUpButton);
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LayoutViewHost"/> class.
        /// </summary>
        /// <param name="ctx">The CTX.</param>
        /// <param name="layoutId">The layout identifier.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="attachToRoot">if set to <c>true</c> [attach to root].</param>
        /// <param name="performAutoWireup">if set to <c>true</c> [perform automatic wireup].</param>
        protected LayoutViewHost(Context ctx, int layoutId, ViewGroup parent, bool attachToRoot = false, bool performAutoWireup = true)
        {
            var inflater = LayoutInflater.FromContext(ctx);

            if (inflater == null)
            {
                return;
            }

            View = inflater.Inflate(layoutId, parent, attachToRoot);

            if (performAutoWireup)
            {
                this.WireUpControls();
            }
        }
Exemple #5
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = LayoutInflater.FromContext(parent.Context).Inflate(
                    Resource.Layout.MainDrawerListItem, parent, false);
                view.Tag = new DrawerItemViewHolder(view);
            }

            var holder = (DrawerItemViewHolder)view.Tag;

            holder.Bind(GetDrawerItem(position));
            return(view);
        }
Exemple #6
0
        async void AutoScan()
        {
            scanner.UseCustomOverlay = true;
            zxingOverlay             = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

            ImageView ivScanning    = zxingOverlay.FindViewById <ImageView>(Resource.Id.ivScanning);
            Button    btnCancelScan = zxingOverlay.FindViewById <Button>(Resource.Id.btnCancelScan);

            btnCancelScan.Click += (s, e) =>
            {
                if (scanner != null)
                {
                    scanner.Cancel();
                }
            };

            zxingOverlay.Measure(MeasureSpecMode.Unspecified.GetHashCode(), MeasureSpecMode.Unspecified.GetHashCode());
            int width  = zxingOverlay.MeasuredWidth;
            int height = zxingOverlay.MeasuredHeight;

            // 从上到下的平移动画
            Animation verticalAnimation = new TranslateAnimation(0, 0, 0, height);

            verticalAnimation.Duration    = 3000;               // 动画持续时间
            verticalAnimation.RepeatCount = Animation.Infinite; // 无限循环

            // 播放动画
            ivScanning.Animation = verticalAnimation;
            verticalAnimation.StartNow();

            scanner.CustomOverlay = zxingOverlay;
            var mbs = MobileBarcodeScanningOptions.Default;

            mbs.AssumeGS1                 = true;
            mbs.AutoRotate                = true;
            mbs.DisableAutofocus          = false;
            mbs.PureBarcode               = false;
            mbs.TryInverted               = true;
            mbs.TryHarder                 = true;
            mbs.UseCode39ExtendedMode     = true;
            mbs.UseFrontCameraIfAvailable = false;
            mbs.UseNativeScanning         = true;

            var result = await scanner.Scan(this, mbs);

            HandleScanResult(result);
        }
        // VIEWS

        public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
        {
            var i     = groupPosition;
            var title = GetGroup(i).ToString();

            if (convertView == null)
            {
                var inflater = LayoutInflater.FromContext(context);
                convertView = inflater.Inflate(Resource.Layout.expandablelistview_parent, null);
            }

            var parentText = (TextView)convertView.FindViewById(Resource.Id.elvTextParent);

            parentText.SetText(title, TextView.BufferType.Normal);

            return(convertView);
        }
Exemple #8
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var item = lastResponse?.Data?.Images?.Image?[position];

            if (item == null)
            {
                return(convertView);
            }

            var view = convertView ?? LayoutInflater.FromContext(Parent).Inflate(Resource.Layout.ListItem, parent, false);

            var imageView = view.FindViewById <ImageView>(Resource.Id.imageView);

            Bumptech.Glide.With(Parent).Load(item.Url).Into(imageView);

            return(view);
        }
Exemple #9
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            //return base.GetView(position, convertView, parent);

            MyBleDevice device = devices[position];

            if (convertView == null)
            {
                convertView = LayoutInflater.FromContext(myContext)
                              .Inflate(Android.Resource.Layout.SimpleListItem2, null);
            }
            ((TextView)convertView.FindViewById <TextView>(Android.Resource.Id.Text1))
            .SetText(device.Device.Name, TextView.BufferType.Normal);
            ((TextView)convertView.FindViewById <TextView>(Android.Resource.Id.Text2))
            .SetText(device.Device.Id.ToString(), TextView.BufferType.Normal);
            return(convertView);
        }
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var view   = LayoutInflater.FromContext(parent.Context).Inflate(Resource.Layout.authListItem, parent, false);
            var holder = new AuthenticatorListHolder(view);

            holder.ItemView.Click += delegate
            {
                ItemClick?.Invoke(this, holder.AdapterPosition);
            };

            holder.ItemView.LongClick += delegate
            {
                ItemLongClick?.Invoke(this, holder.AdapterPosition);
            };

            return(holder);
        }
        protected override View GetModelView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            var entry    = GetEntry(position);
            var viewType = GetItemViewType(position);

            if (viewType == ViewTypeDateHeader)
            {
                var dateGroup = (AllTimeEntriesView.DateGroup)entry;
                if (view == null)
                {
                    view = LayoutInflater.FromContext(ServiceContainer.Resolve <Context> ()).Inflate(
                        Resource.Layout.LogTimeEntryListSectionHeader, parent, false);
                    view.Tag = new HeaderListItemHolder(handler, view);
                }
                var holder = (HeaderListItemHolder)view.Tag;
                holder.Bind(dateGroup);
            }
            else if (viewType == ViewTypeExpanded)
            {
                var data = (TimeEntryData)entry;
                if (view == null)
                {
                    view = LayoutInflater.FromContext(ServiceContainer.Resolve <Context> ()).Inflate(
                        Resource.Layout.LogTimeEntryListExpandedItem, parent, false);
                    view.Tag = new ExpandedListItemHolder(this, view);
                }
                var holder = (ExpandedListItemHolder)view.Tag;
                holder.Bind((TimeEntryModel)data);
            }
            else
            {
                var data  = (TimeEntryData)entry;
                var model = (TimeEntryModel)data;
                if (view == null)
                {
                    view     = new LogTimeEntryItem(ServiceContainer.Resolve <Context> (), (IAttributeSet)null);
                    view.Tag = new TimeEntryListItemHolder(handler, this, view);
                }
                var holder = (TimeEntryListItemHolder)view.Tag;
                holder.Bind(model);
            }

            return(view);
        }
Exemple #12
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView ?? LayoutInflater.FromContext(Owner).Inflate(Resource.Layout.ImageCell, null);

            var fish = Owner.ViewModel.Fish[position];

            var text = view.FindViewById <TextView>(Resource.Id.Title);

            text.Text = fish.Name;

            var imageId = Owner.Resources.GetIdentifier(fish.ImageSource, "drawable", Owner.PackageName);
            var image   = view.FindViewById <ImageView>(Resource.Id.Thumbnail);

            image.SetImageResource(imageId);

            return(view);
        }
Exemple #13
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var context = Application.Context;

            var view = convertView ?? LayoutInflater.FromContext(context).Inflate(Android.Resource.Layout.ActivityListItem, null);

            var item = _dataSource[position];
            var text = view.FindViewById <TextView>(Android.Resource.Id.Text1);

            text.Text = TextFunc == null?item.ToString() : TextFunc(item);

            var imageView = view.FindViewById <ImageView>(Android.Resource.Id.Icon);

            LoadImageAsync(imageView, new Uri(UriFunc(item)));

            return(view);
        }
Exemple #14
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var item = _items[position];
            var view = convertView;

            if (view == null)
            {
                var inflater = LayoutInflater.FromContext(_context);
                view = inflater.Inflate(Resource.Layout.listviewCOMBO, parent, false);
            }

            view.FindViewById <TextView>(Resource.Id.tvNombre).Text = item.nombre;
            view.FindViewById <TextView>(Resource.Id.tvNro).Text    = item.id.ToString();


            return(view);
        }
Exemple #15
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var item = _items[position];
            var view = convertView;

            if (view == null)
            {
                var inflater = LayoutInflater.FromContext(_context);
                view = inflater.Inflate(Resource.Layout.listFaultTemplate, parent, false);
            }

            view.FindViewById <TextView>(Resource.Id.FirstText).Text  = item.colNo.ToString();
            view.FindViewById <TextView>(Resource.Id.SecondText).Text = item.colFault;
            view.FindViewById <TextView>(Resource.Id.ThirdText).Text  = item.colStatus;

            return(view);
        }
Exemple #16
0
        public NativeCustomCell(Context context, Cell formsCell) : base(context)
        {
            Cell = formsCell;

            SetMinimumHeight((int)context.ToPixels(44));

            //Layout呼び出して親とドッキングする(AddViewする必要無し)
            var contentView = LayoutInflater.FromContext(context).Inflate(Resource.Layout.NativeCustomCellLayout, this, true);

            //必要部品を取り出す
            _titleLabel = contentView.FindViewById <TextView>(Resource.Id.TitleLabel);

            _titleLabel.Click += (sender, e) =>
            {
                CustomCell.Command?.Execute(_titleLabel.Text);
            };
        }
Exemple #17
0
        private void InitializeView(Context context, IAttributeSet attrs)
        {
            LayoutInflater.FromContext(context).Inflate(Resource.Layout.custom_loader_panel, this);
            _overlay          = FindViewById <FrameLayout>(Resource.Id.loading_overlay);
            _contentContainer = FindViewById <FrameLayout>(Resource.Id.content);

            if (attrs == null)
            {
                return;
            }

            var allStyles = context.ObtainStyledAttributes(attrs, Resource.Styleable.LoaderPanel, 0, 0);

            OverlayVisible = allStyles.GetBoolean(Resource.Styleable.LoaderPanel_is_panel_visible, false);

            allStyles.Recycle();
        }
Exemple #18
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            if (convertView == null)
            {
                convertView = LayoutInflater.FromContext(Context).Inflate(Resource.Layout.ListItem, null, false);
            }

            Food food = GetItem(position);

            TextView name     = convertView.FindViewById <TextView>(Resource.Id.name);
            TextView category = convertView.FindViewById <TextView>(Resource.Id.category);

            name.Text     = food.Name;
            category.Text = food.Category;

            return(convertView);
        }
        void Init(Context context, IAttributeSet attrs)
        {
            var inflater = LayoutInflater.FromContext(context);

            inflater.Inflate(Resource.Layout.calendar_view_button, this);

            iconView = FindViewById <MvxImageView>(Resource.Id.icon_range_view);
            textView = FindViewById <TextView>(Resource.Id.text_range_view);

            var attr = context.ObtainStyledAttributes(attrs, Resource.Styleable.CalendarRangeButton);

            iconView?.SetImageDrawable(attr.GetDrawable(Resource.Styleable.CalendarRangeButton_icon_calendar));

            Text = attr.GetString(Resource.Styleable.CalendarRangeButton_text_calendar_field);

            attr.Recycle();
        }
        protected override View GetCellCore(Xamarin.Forms.Cell item, View convertView, ViewGroup parent, Context context)
        {
            var            viewModel      = (ScavengerHuntCellViewModel)item.BindingContext;
            LayoutInflater layoutInflater = LayoutInflater.FromContext(context);

            var view = convertView;

            if (view == null)
            {
                view = layoutInflater.Inflate(Resource.Layout.ScavengerHuntCell, null);
            }

            SetupLabel(view, viewModel, Color.Black);
            SetupImage(view, viewModel);

            return(view);
        }
Exemple #21
0
        public static MyToast Create(Context context, int iconResId, string msg, ToastLength duration)
        {
            View     wrap  = LayoutInflater.FromContext(context).Inflate(Resource.Layout.toast_bg, null);
            TextView tvMsg = (TextView)wrap.FindViewById(Resource.Id.tv_msg);

            tvMsg.SetText(msg, TextView.BufferType.Normal);
            ImageView ivIcon = (ImageView)wrap.FindViewById(Resource.Id.iv_icon);

            ivIcon.SetImageResource(iconResId);

            MyToast toast = new MyToast(context);

            toast.View = wrap;
            toast.SetGravity(GravityFlags.CenterVertical, 0, 0);
            toast.Duration = duration;
            return(toast);
        }
Exemple #22
0
        protected virtual View GetLoadIndicatorView(int position, View convertView, ViewGroup parent)
        {
            if (convertView != null)
            {
                return(convertView);
            }

            var view = LayoutInflater.FromContext(parent.Context).Inflate(
                Resource.Layout.TimeEntryListLoadingItem, parent, false);

            ImageView spinningImage          = view.FindViewById <ImageView> (Resource.Id.LoadingImageView);
            Animation spinningImageAnimation = AnimationUtils.LoadAnimation(parent.Context, Resource.Animation.SpinningAnimation);

            spinningImage.StartAnimation(spinningImageAnimation);

            return(view);
        }
Exemple #23
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                ShapeImageViewQs.Src.SampleBubbleFragment.ViewHolder holder;

                int itemViewType = GetItemViewType(position);
                int layout       = layout1;

                if (itemViewType == 1)
                {
                    layout = layout2;
                }

                if (convertView == null)
                {
                    convertView     = LayoutInflater.FromContext(Context).Inflate(layout, parent, false);
                    holder          = new ViewHolder();
                    holder.image    = convertView.FindViewById <ImageView>(Resource.Id.image);
                    holder.text     = convertView.FindViewById <TextView>(Resource.Id.text);
                    convertView.Tag = holder;
                }
                else
                {
                    holder = (ViewHolder)convertView.Tag;
                }

                position = position % MESSAGES.Length;

                string url;
                string text = MESSAGES[position];

                if (position < 4)
                {
                    url = IMAGES[0, 0];
                }
                else
                {
                    url = IMAGES[1, 0];
                }

                holder.text.Text = text;
                picasso.Load(url)
                .Placeholder(Resource.Drawable.placeholder)
                .Into(holder.image);
                return(convertView);
            }
Exemple #24
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ViewHolder holder;

            // TODO: Step 2a - view recycling is a must.
            View view = convertView;

            if (view == null)
            {
                view = LayoutInflater.FromContext(context).Inflate(Resource.Layout.TodoItemCell, parent, false);

                // TODO: Step 2b - cache off the view holder into the tag.
                holder = new ViewHolder()
                {
                    TextView   = view.FindViewById <TextView>(Resource.Id.label),
                    DetailView = view.FindViewById <TextView>(Resource.Id.details),
                    ImageView  = view.FindViewById <ImageView>(Resource.Id.icon)
                };
                view.Tag = holder;

                // TODO: Step 2c - Set the icon once to our shared value.
                Bitmap checkImage = null;
                checkImage = (checkImageCache != null) ? (Bitmap)checkImageCache.Target : null;
                if (checkImage == null)
                {
                    // TODO: Step 2c - Use proper size bitmap.
                    checkImage      = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.small_check);
                    checkImageCache = new WeakReference(checkImage);
                }
                holder.ImageView.SetImageBitmap(checkImage);
            }
            else
            {
                holder = (ViewHolder)view.Tag;
            }

            var item = data[position];

            holder.TextView.Text   = item.Title;
            holder.DetailView.Text = item.Notes;
            // TODO: Step 2c - Hide and show checkmark vs. setting image
            holder.ImageView.Visibility = (item.Completed) ? ViewStates.Visible : ViewStates.Invisible;

            return(view);
        }
Exemple #25
0
        protected virtual AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context)
        {
            Performance.Start(out string reference, "GetCellCore");

            LayoutInflater inflater = LayoutInflater.FromContext(context);
            const int      type     = global::Android.Resource.Layout.SimpleListItem1;
            AView          view     = inflater.Inflate(type, null);

            var textView = view.FindViewById <TextView>(global::Android.Resource.Id.Text1);

            textView.Text = item.ToString();
            textView.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            view.SetBackgroundColor(global::Android.Graphics.Color.Black);

            Performance.Stop(reference, "GetCellCore");

            return(view);
        }
Exemple #26
0
        private void AddImages(List <Uri> urls)
        {
            try
            {
                LayoutInflater inflator = LayoutInflater.FromContext(this);

                foreach (Uri uri in urls)
                {
                    LinearLayout layout = (LinearLayout)inflator.Inflate(Resource.Layout.ImageCard, null, false);
                    ImageView    image  = layout.FindViewById <ImageView>(Resource.Id.NewsImage);

                    baseLayout.AddView(layout);

                    Picasso.With(this).Load(uri.ToString()).Into(image);
                }
            }
            catch { }
        }
        /// <summary>
        /// ExpandableListAdapter constructor. Set up a long click listener and the group expander helper class
        /// </summary>
        /// <param name="context"></param>
        /// <param name="view"></param>
        /// <param name="provider"></param>
        public ExpandableListAdapter(Context context, ExpandableListView view, IGroupContentsProvider <T> provider,
                                     ExpandableListAdapterModel model, IAdapterEventHandler stateChange)
        {
            // Save the parameters
            adapterModel        = model;
            contentsProvider    = provider;
            parentView          = view;
            stateChangeReporter = stateChange;

            // Save the inflator to use when creating the item views
            inflator = LayoutInflater.FromContext(context);

            // Set up listeners for group and child selection and item long click
            parentView.SetOnGroupClickListener(this);
            parentView.SetOnChildClickListener(this);
            parentView.OnItemLongClickListener = this;
            parentView.SetOnScrollListener(this);
        }
        public override Object InstantiateItem(ViewGroup container, int position)
        {
            var inflater     = LayoutInflater.FromContext(context);
            var inflatedView = inflater.Inflate(Resource.Layout.ReportsCalendarFragmentPage, container, false);

            var calendarRecyclerView = (ReportsCalendarRecyclerView)inflatedView;

            calendarRecyclerView.SetRecycledViewPool(recyclerviewPool);
            calendarRecyclerView.SetLayoutManager(new ReportsCalendarLayoutManager(context));

            setupAdapter(calendarRecyclerView, position);

            recyclerViews[position] = calendarRecyclerView;

            container.AddView(inflatedView);

            return(inflatedView);
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var  item = defects[position];
            View view = convertView;

            if (view == null)
            {
                var inflater = LayoutInflater.FromContext(context);
                view = inflater.Inflate(Resource.Layout.defect_layout, null);
            }
            view.FindViewById <TextView>(Resource.Id.defectIDview).Text = item.Id;
            view.FindViewById <TextView>(Resource.Id.reportText).Text   = item.ReportedOn;
            view.FindViewById <TextView>(Resource.Id.faultyText).Text   = item.Type;
            view.FindViewById <TextView>(Resource.Id.OverdueText).Text  = item.Overdue.ToString();
            view.FindViewById <TextView>(Resource.Id.textView7).Text    = item.Critical.ToString();

            return(view);
        }
Exemple #30
0
        public static View LoadLayout(Context context, ViewGroup parent, int resourceId)
        {
            try
            {
                var inflater = LayoutInflater.FromContext(context);

                return(inflater.Inflate(resourceId, parent, false));
            }
            catch (InflateException ex)
            {
                Log.Error("Android.Dialog", "Inflate failed: " + ex.Cause.Message);
            }
            catch (Exception ex)
            {
                Log.Error("Android.Dialog", "LoadLayout failed: " + ex.Message);
            }
            return(null);
        }