-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageAdapter.cs
83 lines (71 loc) · 2.33 KB
/
ImageAdapter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using Android.Content;
using Android.Views;
using Android.Widget;
using Android.Support.V4.View;
namespace XamarinAndroidCarousel
{
public class ImageAdapter : PagerAdapter
{
private Context context;
private int[] imageList;
public ImageAdapter(Context context) {
this.context = context;
}
public ImageAdapter(Context context, int[] imageList)
{
this.context = context;
this.imageList = imageList;
}
public override int Count
{
get
{
return imageList.Length;
}
}
public override bool IsViewFromObject(View view, Java.Lang.Object objectValue)
{
return view == (ImageView)objectValue;
}
[Obsolete]
public override Java.Lang.Object InstantiateItem(View container, int position)
{
ImageView imageView = new ImageView(context);
imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
imageView.SetImageResource(imageList[position]);
((ViewPager)container).AddView(imageView, 0);
return imageView;
}
public override Java.Lang.Object InstantiateItem(ViewGroup container, int position)
{
ImageView imageView = new ImageView(context);
imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
imageView.SetImageResource(imageList[position]);
container.AddView(imageView, 0);
return imageView;
}
[Obsolete]
public override void DestroyItem(View container, int position, Java.Lang.Object objectValue)
{
((ViewPager)container).RemoveView((ImageView)objectValue);
}
public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object objectValue)
{
container.RemoveView((ImageView)objectValue);
}
public override void FinishUpdate(ViewGroup container)
{
base.FinishUpdate(container);
}
public override void StartUpdate(ViewGroup container)
{
base.StartUpdate(container);
}
[Obsolete]
public override void StartUpdate(View container)
{
base.StartUpdate(container);
}
}
}