Ejemplo n.º 1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView;

            if (view == null)
            {
                var inflater = LayoutInflater.From(parent.Context);
                view = inflater.Inflate(Resource.Layout.InstructorRow, parent, false);

                var p = view.FindViewById <ImageView>(Resource.Id.photoImageView);
                var n = view.FindViewById <TextView>(Resource.Id.nameTextView);
                var s = view.FindViewById <TextView>(Resource.Id.specialtyTextView);

                view.Tag = new ViewHolder {
                    Photo = p, Name = n, Specialty = s
                };
            }

            var holder = (ViewHolder)view.Tag;


            holder.Name.Text      = instructors[position].Name;
            holder.Specialty.Text = instructors[position].Specialty;

            //Stream stream = parent.Context.Assets.Open(instructors[position].ImageUrl);
            //Drawable drawable = Drawable.CreateFromStream(stream,null);
            holder.Photo.SetImageDrawable(ImageAssetManager.Get(parent.Context, instructors[position].ImageUrl));

            return(view);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.InstructorDetails);

            var position   = Intent.GetIntExtra("position", -1);
            var instructor = InstructorData.Instructors[position];

            var photo     = FindViewById <ImageView>(Resource.Id.photoImageView);
            var name      = FindViewById <TextView>(Resource.Id.nameTextView);
            var specialty = FindViewById <TextView>(Resource.Id.specialtyTextView);
            var biography = FindViewById <TextView>(Resource.Id.biographyTextView);

            photo.SetImageDrawable(ImageAssetManager.Get(this, instructor.ImageUrl));
            name.Text      = instructor.Name;
            specialty.Text = instructor.Specialty;
            biography.Text = instructor.Biography;
        }