public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment View v = inflater.Inflate(Resource.Layout.component_verb, container, false); spinner = v.FindViewById<Spinner>(Resource.Id.spinner_verb_ending); ArrayAdapter adapter = ArrayAdapter.CreateFromResource(Activity, Resource.Array.verb_ending, Android.Resource.Layout.SimpleSpinnerItem); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinner.Adapter = adapter; button = v.FindViewById<ToggleButton>(Resource.Id.button_regular); conjugationList = v.FindViewById<AdapterViewFlipper>(Resource.Id.list_conjugations); conjugationAdapter = new ConjugationAdapter(Activity, Resource.Layout.cell_conjugations, conjugations); conjugationList.Adapter = conjugationAdapter; nextButton = v.FindViewById<ImageButton>(Resource.Id.next_image_button); nextButton.Click += (sender, e) => conjugationAdapter.NextView(); prevButton = v.FindViewById<ImageButton>(Resource.Id.prev_image_button); prevButton.Click += (sender, e) => conjugationAdapter.PrevView(); return v; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here var mContext = this; SetContentView(Resource.Layout.Fullscreen_view); mViewFlipper = (AdapterViewFlipper)FindViewById(Resource.Id.adpater_view_flipper); var listener = new SwipeOnGestureListener(AppConstant.SWIPE_MIN_DISTANCE, AppConstant.SWIPE_THRESHOLD_VELOCITY); var detector = new GestureDetector(listener); mViewFlipper.Touch += (sender, e) => { detector.OnTouchEvent(e.Event); }; listener.Next += (sender, e) => { mViewFlipper.SetInAnimation(mContext, Resource.Animation.left_in_obj); mViewFlipper.SetOutAnimation(mContext, Resource.Animation.left_out_obj); mViewFlipper.ShowNext(); }; listener.Previous += (sender, e) => { mViewFlipper.SetInAnimation(mContext, Resource.Animation.right_in_obj); mViewFlipper.SetOutAnimation(mContext, Resource.Animation.right_out_obj); mViewFlipper.ShowPrevious(); }; int position = Intent.GetIntExtra("position", 0); var imagePaths = Utils.GetFileInfos(AppConstant.PHOTO_ALBUM, AppConstant.FILE_EXTN).Select(x => x.FullName); adapter = new ViewAdapter(() => imagePaths.Count(), (pos, oldView) => { var viewLayout = oldView != null ? oldView : this.LayoutInflater.Inflate(Resource.Layout.Fullscreen_image, mViewFlipper, false); var imgDisplay = (TouchImageView)viewLayout.FindViewById(Resource.Id.imgDisplay); imgDisplay.SetScaleType(ImageView.ScaleType.CenterInside); if (viewLayout != oldView) { // close button click event var btnClose = viewLayout.FindViewById(Resource.Id.btnClose); btnClose.Click += (sender, e) => this.Finish(); } //BitmapFactory.Options options = new BitmapFactory.Options(); //options.InPreferredConfig = Bitmap.Config.Argb8888; //Bitmap bitmap = BitmapFactory.DecodeFile(imagePaths.ElementAt(pos), options); Task.Run <Bitmap>(() => Utils.LoadAndResizeBitmap(imagePaths.ElementAt(pos), Resources.DisplayMetrics.WidthPixels, Resources.DisplayMetrics.HeightPixels)).ContinueWith(x => imgDisplay.SetImageBitmap(x.Result), TaskScheduler.FromCurrentSynchronizationContext()); return(viewLayout); }); mViewFlipper.Adapter = adapter; // displaying selected image first mViewFlipper.SetSelection(position); }